{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "agricultural-stephen",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "damaged-doctor",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "current-tattoo",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -3.87305286,   5.21469633,   0.96846166, ...,   4.38721299,\n",
       "         -1.14636396,  -3.22761453],\n",
       "       [  0.28463482,  -2.62490892,   0.80262424, ...,  -1.93265915,\n",
       "         -6.57078459,  -5.95983537],\n",
       "       [  2.49997293,   0.0587137 ,  -1.43283557, ...,   1.99362731,\n",
       "          3.9228198 ,   4.68115696],\n",
       "       ...,\n",
       "       [ -0.5370573 ,  -4.22276226,  -3.80106751, ...,  -3.92358771,\n",
       "         -0.16495815,   4.66335535],\n",
       "       [ -6.60700065,   2.31443285,   7.45858127, ...,   3.3610305 ,\n",
       "         -8.9038306 ,  -0.87605743],\n",
       "       [ -0.8307142 ,  -2.6553264 , -11.23433124, ...,   3.35111026,\n",
       "          2.5182014 ,  -4.14102465]])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_day_rise = np.random.normal(0, 4, (500, 504))\n",
    "stock_day_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "motivated-breed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>494</th>\n",
       "      <th>495</th>\n",
       "      <th>496</th>\n",
       "      <th>497</th>\n",
       "      <th>498</th>\n",
       "      <th>499</th>\n",
       "      <th>500</th>\n",
       "      <th>501</th>\n",
       "      <th>502</th>\n",
       "      <th>503</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "          0         1          2         3         4          5         6    \\\n",
       "0   -3.873053  5.214696   0.968462  0.257947  7.145218   3.726503  0.048677   \n",
       "1    0.284635 -2.624909   0.802624 -9.770720  1.286965   0.371357 -2.877826   \n",
       "2    2.499973  0.058714  -1.432836  3.467607  0.393309  -2.593841  2.718229   \n",
       "3   -7.130197  5.386551  -3.584072 -5.698062 -0.811168  11.684473 -0.188643   \n",
       "4    2.757527  0.923505   1.065218  0.831143  2.161252   0.001553  2.597266   \n",
       "..        ...       ...        ...       ...       ...        ...       ...   \n",
       "495 -6.190970 -8.096143   8.363273  2.833073  1.980141  -1.983746 -2.724166   \n",
       "496  1.106526 -1.860937  -4.527927 -2.618610 -0.440584   0.284029  1.474065   \n",
       "497 -0.537057 -4.222762  -3.801068 -4.104841  3.296883   6.116682  4.286740   \n",
       "498 -6.607001  2.314433   7.458581 -7.153377 -0.326586   4.483198  2.086438   \n",
       "499 -0.830714 -2.655326 -11.234331 -0.185842 -3.590396   1.095979  2.130168   \n",
       "\n",
       "          7          8         9    ...       494       495       496  \\\n",
       "0    2.129644  -2.672674  1.997563  ... -0.428511 -8.970102 -3.286372   \n",
       "1   -1.509765  -3.167601 -1.633638  ...  0.554594 -3.045685 -2.507414   \n",
       "2   -1.129107  -2.780722 -6.705974  ... -4.998007  1.183721 -2.565804   \n",
       "3   -6.596933  10.824887 -2.422804  ...  0.995424 -4.364533  1.279477   \n",
       "4   -0.095404  -0.422169  1.093598  ... -1.090444  2.188031  5.767458   \n",
       "..        ...        ...       ...  ...       ...       ...       ...   \n",
       "495 -1.070691  -2.610054 -1.646262  ... -2.184017  5.092414  1.600926   \n",
       "496 -7.136713  -0.717531 -4.495082  ... -8.072072  3.216294  3.585040   \n",
       "497 -8.228282  -6.515674 -0.261289  ... -0.307919  6.509931  1.805440   \n",
       "498 -4.955616   0.080462 -9.214175  ...  3.728769 -0.799284 -2.611056   \n",
       "499 -5.170259   0.442787 -1.196191  ...  1.817441  3.433802 -9.659011   \n",
       "\n",
       "          497        498       499       500       501       502       503  \n",
       "0   -5.868192  -2.407854 -2.537963 -4.785395  4.387213 -1.146364 -3.227615  \n",
       "1   -0.934476   2.114796 -2.158530  2.319398 -1.932659 -6.570785 -5.959835  \n",
       "2    0.631494  10.390756 -2.505270  3.038020  1.993627  3.922820  4.681157  \n",
       "3   -2.123249  -1.379309  2.467084  8.437016 -0.558287 -5.979503 -4.754668  \n",
       "4   -1.034012   2.337551  0.656146  5.929354 -4.710914  2.428449 -0.331959  \n",
       "..        ...        ...       ...       ...       ...       ...       ...  \n",
       "495  8.170517   4.310092 -6.547008 -1.069861  5.337184  3.628220 -1.801981  \n",
       "496  0.384871   4.979088  0.773292  2.908074  7.449028  0.732703 -4.740213  \n",
       "497  0.602975   4.177174 -1.677018 -4.870802 -3.923588 -0.164958  4.663355  \n",
       "498 -2.263950   2.990817 -2.209798 -1.198215  3.361030 -8.903831 -0.876057  \n",
       "499  2.189575  -0.893896 -1.330415  1.752599  3.351110  2.518201 -4.141025  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用Pandas中的数据结构\n",
    "stock_day_rise_df = pd.DataFrame(stock_day_rise)\n",
    "stock_day_rise_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "selected-niger",
   "metadata": {},
   "outputs": [],
   "source": [
    "#构造行索引索引序列\n",
    "stock_code = ['股票' + str(i) for i in range(stock_day_rise.shape[0])]   # [\"股票0\",\"股票1\",...\"股票499\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "gross-fountain",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "      <th>1</th>\n",
       "      <th>2</th>\n",
       "      <th>3</th>\n",
       "      <th>4</th>\n",
       "      <th>5</th>\n",
       "      <th>6</th>\n",
       "      <th>7</th>\n",
       "      <th>8</th>\n",
       "      <th>9</th>\n",
       "      <th>...</th>\n",
       "      <th>494</th>\n",
       "      <th>495</th>\n",
       "      <th>496</th>\n",
       "      <th>497</th>\n",
       "      <th>498</th>\n",
       "      <th>499</th>\n",
       "      <th>500</th>\n",
       "      <th>501</th>\n",
       "      <th>502</th>\n",
       "      <th>503</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            0         1          2         3         4          5         6    \\\n",
       "股票0   -3.873053  5.214696   0.968462  0.257947  7.145218   3.726503  0.048677   \n",
       "股票1    0.284635 -2.624909   0.802624 -9.770720  1.286965   0.371357 -2.877826   \n",
       "股票2    2.499973  0.058714  -1.432836  3.467607  0.393309  -2.593841  2.718229   \n",
       "股票3   -7.130197  5.386551  -3.584072 -5.698062 -0.811168  11.684473 -0.188643   \n",
       "股票4    2.757527  0.923505   1.065218  0.831143  2.161252   0.001553  2.597266   \n",
       "...         ...       ...        ...       ...       ...        ...       ...   \n",
       "股票495 -6.190970 -8.096143   8.363273  2.833073  1.980141  -1.983746 -2.724166   \n",
       "股票496  1.106526 -1.860937  -4.527927 -2.618610 -0.440584   0.284029  1.474065   \n",
       "股票497 -0.537057 -4.222762  -3.801068 -4.104841  3.296883   6.116682  4.286740   \n",
       "股票498 -6.607001  2.314433   7.458581 -7.153377 -0.326586   4.483198  2.086438   \n",
       "股票499 -0.830714 -2.655326 -11.234331 -0.185842 -3.590396   1.095979  2.130168   \n",
       "\n",
       "            7          8         9    ...       494       495       496  \\\n",
       "股票0    2.129644  -2.672674  1.997563  ... -0.428511 -8.970102 -3.286372   \n",
       "股票1   -1.509765  -3.167601 -1.633638  ...  0.554594 -3.045685 -2.507414   \n",
       "股票2   -1.129107  -2.780722 -6.705974  ... -4.998007  1.183721 -2.565804   \n",
       "股票3   -6.596933  10.824887 -2.422804  ...  0.995424 -4.364533  1.279477   \n",
       "股票4   -0.095404  -0.422169  1.093598  ... -1.090444  2.188031  5.767458   \n",
       "...         ...        ...       ...  ...       ...       ...       ...   \n",
       "股票495 -1.070691  -2.610054 -1.646262  ... -2.184017  5.092414  1.600926   \n",
       "股票496 -7.136713  -0.717531 -4.495082  ... -8.072072  3.216294  3.585040   \n",
       "股票497 -8.228282  -6.515674 -0.261289  ... -0.307919  6.509931  1.805440   \n",
       "股票498 -4.955616   0.080462 -9.214175  ...  3.728769 -0.799284 -2.611056   \n",
       "股票499 -5.170259   0.442787 -1.196191  ...  1.817441  3.433802 -9.659011   \n",
       "\n",
       "            497        498       499       500       501       502       503  \n",
       "股票0   -5.868192  -2.407854 -2.537963 -4.785395  4.387213 -1.146364 -3.227615  \n",
       "股票1   -0.934476   2.114796 -2.158530  2.319398 -1.932659 -6.570785 -5.959835  \n",
       "股票2    0.631494  10.390756 -2.505270  3.038020  1.993627  3.922820  4.681157  \n",
       "股票3   -2.123249  -1.379309  2.467084  8.437016 -0.558287 -5.979503 -4.754668  \n",
       "股票4   -1.034012   2.337551  0.656146  5.929354 -4.710914  2.428449 -0.331959  \n",
       "...         ...        ...       ...       ...       ...       ...       ...  \n",
       "股票495  8.170517   4.310092 -6.547008 -1.069861  5.337184  3.628220 -1.801981  \n",
       "股票496  0.384871   4.979088  0.773292  2.908074  7.449028  0.732703 -4.740213  \n",
       "股票497  0.602975   4.177174 -1.677018 -4.870802 -3.923588 -0.164958  4.663355  \n",
       "股票498 -2.263950   2.990817 -2.209798 -1.198215  3.361030 -8.903831 -0.876057  \n",
       "股票499  2.189575  -0.893896 -1.330415  1.752599  3.351110  2.518201 -4.141025  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 添加行索引\n",
    "data = pd.DataFrame(stock_day_rise, index=stock_code)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "twelve-street",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04', '2017-01-05',\n",
       "               '2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11',\n",
       "               '2017-01-12', '2017-01-13',\n",
       "               ...\n",
       "               '2018-11-23', '2018-11-26', '2018-11-27', '2018-11-28',\n",
       "               '2018-11-29', '2018-11-30', '2018-12-03', '2018-12-04',\n",
       "               '2018-12-05', '2018-12-06'],\n",
       "              dtype='datetime64[ns]', length=504, freq='B')"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 生成一个时间的序列，略过周末非交易日\n",
    "date = pd.date_range('2017-01-01', periods=stock_day_rise.shape[1], freq='B')\n",
    "date"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "waiting-victorian",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票0     -3.873053    5.214696    0.968462    0.257947    7.145218    3.726503   \n",
       "股票1      0.284635   -2.624909    0.802624   -9.770720    1.286965    0.371357   \n",
       "股票2      2.499973    0.058714   -1.432836    3.467607    0.393309   -2.593841   \n",
       "股票3     -7.130197    5.386551   -3.584072   -5.698062   -0.811168   11.684473   \n",
       "股票4      2.757527    0.923505    1.065218    0.831143    2.161252    0.001553   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495   -6.190970   -8.096143    8.363273    2.833073    1.980141   -1.983746   \n",
       "股票496    1.106526   -1.860937   -4.527927   -2.618610   -0.440584    0.284029   \n",
       "股票497   -0.537057   -4.222762   -3.801068   -4.104841    3.296883    6.116682   \n",
       "股票498   -6.607001    2.314433    7.458581   -7.153377   -0.326586    4.483198   \n",
       "股票499   -0.830714   -2.655326  -11.234331   -0.185842   -3.590396    1.095979   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票0      0.048677    2.129644   -2.672674    1.997563  ...   -0.428511   \n",
       "股票1     -2.877826   -1.509765   -3.167601   -1.633638  ...    0.554594   \n",
       "股票2      2.718229   -1.129107   -2.780722   -6.705974  ...   -4.998007   \n",
       "股票3     -0.188643   -6.596933   10.824887   -2.422804  ...    0.995424   \n",
       "股票4      2.597266   -0.095404   -0.422169    1.093598  ...   -1.090444   \n",
       "...           ...         ...         ...         ...  ...         ...   \n",
       "股票495   -2.724166   -1.070691   -2.610054   -1.646262  ...   -2.184017   \n",
       "股票496    1.474065   -7.136713   -0.717531   -4.495082  ...   -8.072072   \n",
       "股票497    4.286740   -8.228282   -6.515674   -0.261289  ...   -0.307919   \n",
       "股票498    2.086438   -4.955616    0.080462   -9.214175  ...    3.728769   \n",
       "股票499    2.130168   -5.170259    0.442787   -1.196191  ...    1.817441   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票0     -8.970102   -3.286372   -5.868192   -2.407854   -2.537963   -4.785395   \n",
       "股票1     -3.045685   -2.507414   -0.934476    2.114796   -2.158530    2.319398   \n",
       "股票2      1.183721   -2.565804    0.631494   10.390756   -2.505270    3.038020   \n",
       "股票3     -4.364533    1.279477   -2.123249   -1.379309    2.467084    8.437016   \n",
       "股票4      2.188031    5.767458   -1.034012    2.337551    0.656146    5.929354   \n",
       "...           ...         ...         ...         ...         ...         ...   \n",
       "股票495    5.092414    1.600926    8.170517    4.310092   -6.547008   -1.069861   \n",
       "股票496    3.216294    3.585040    0.384871    4.979088    0.773292    2.908074   \n",
       "股票497    6.509931    1.805440    0.602975    4.177174   -1.677018   -4.870802   \n",
       "股票498   -0.799284   -2.611056   -2.263950    2.990817   -2.209798   -1.198215   \n",
       "股票499    3.433802   -9.659011    2.189575   -0.893896   -1.330415    1.752599   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "股票0      4.387213   -1.146364   -3.227615  \n",
       "股票1     -1.932659   -6.570785   -5.959835  \n",
       "股票2      1.993627    3.922820    4.681157  \n",
       "股票3     -0.558287   -5.979503   -4.754668  \n",
       "股票4     -4.710914    2.428449   -0.331959  \n",
       "...           ...         ...         ...  \n",
       "股票495    5.337184    3.628220   -1.801981  \n",
       "股票496    7.449028    0.732703   -4.740213  \n",
       "股票497   -3.923588   -0.164958    4.663355  \n",
       "股票498    3.361030   -8.903831   -0.876057  \n",
       "股票499    3.351110    2.518201   -4.141025  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# index代表行索引，columns代表列索引\n",
    "data = pd.DataFrame(stock_day_rise, index=stock_code, columns=date)\n",
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "loving-hampton",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(500, 504)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "spectacular-oklahoma",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2017-01-02    float64\n",
       "2017-01-03    float64\n",
       "2017-01-04    float64\n",
       "2017-01-05    float64\n",
       "2017-01-06    float64\n",
       "               ...   \n",
       "2018-11-30    float64\n",
       "2018-12-03    float64\n",
       "2018-12-04    float64\n",
       "2018-12-05    float64\n",
       "2018-12-06    float64\n",
       "Freq: B, Length: 504, dtype: object"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.dtypes   # pandas每一列的数据类型可能不一样"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "accompanied-fourth",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "extended-spoke",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ -3.87305286,   5.21469633,   0.96846166, ...,   4.38721299,\n",
       "         -1.14636396,  -3.22761453],\n",
       "       [  0.28463482,  -2.62490892,   0.80262424, ...,  -1.93265915,\n",
       "         -6.57078459,  -5.95983537],\n",
       "       [  2.49997293,   0.0587137 ,  -1.43283557, ...,   1.99362731,\n",
       "          3.9228198 ,   4.68115696],\n",
       "       ...,\n",
       "       [ -0.5370573 ,  -4.22276226,  -3.80106751, ...,  -3.92358771,\n",
       "         -0.16495815,   4.66335535],\n",
       "       [ -6.60700065,   2.31443285,   7.45858127, ...,   3.3610305 ,\n",
       "         -8.9038306 ,  -0.87605743],\n",
       "       [ -0.8307142 ,  -2.6553264 , -11.23433124, ...,   3.35111026,\n",
       "          2.5182014 ,  -4.14102465]])"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "statutory-asbestos",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['股票0', '股票1', '股票2', '股票3', '股票4', '股票5', '股票6', '股票7', '股票8', '股票9',\n",
       "       ...\n",
       "       '股票490', '股票491', '股票492', '股票493', '股票494', '股票495', '股票496', '股票497',\n",
       "       '股票498', '股票499'],\n",
       "      dtype='object', length=500)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "established-exploration",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "DatetimeIndex(['2017-01-02', '2017-01-03', '2017-01-04', '2017-01-05',\n",
       "               '2017-01-06', '2017-01-09', '2017-01-10', '2017-01-11',\n",
       "               '2017-01-12', '2017-01-13',\n",
       "               ...\n",
       "               '2018-11-23', '2018-11-26', '2018-11-27', '2018-11-28',\n",
       "               '2018-11-29', '2018-11-30', '2018-12-03', '2018-12-04',\n",
       "               '2018-12-05', '2018-12-06'],\n",
       "              dtype='datetime64[ns]', length=504, freq='B')"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "beneficial-interaction",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>股票0</th>\n",
       "      <th>股票1</th>\n",
       "      <th>股票2</th>\n",
       "      <th>股票3</th>\n",
       "      <th>股票4</th>\n",
       "      <th>股票5</th>\n",
       "      <th>股票6</th>\n",
       "      <th>股票7</th>\n",
       "      <th>股票8</th>\n",
       "      <th>股票9</th>\n",
       "      <th>...</th>\n",
       "      <th>股票490</th>\n",
       "      <th>股票491</th>\n",
       "      <th>股票492</th>\n",
       "      <th>股票493</th>\n",
       "      <th>股票494</th>\n",
       "      <th>股票495</th>\n",
       "      <th>股票496</th>\n",
       "      <th>股票497</th>\n",
       "      <th>股票498</th>\n",
       "      <th>股票499</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2017-01-02</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>0.284635</td>\n",
       "      <td>2.499973</td>\n",
       "      <td>-7.130197</td>\n",
       "      <td>2.757527</td>\n",
       "      <td>-2.395872</td>\n",
       "      <td>0.358470</td>\n",
       "      <td>4.144862</td>\n",
       "      <td>2.890377</td>\n",
       "      <td>-6.015645</td>\n",
       "      <td>...</td>\n",
       "      <td>0.285004</td>\n",
       "      <td>4.571598</td>\n",
       "      <td>0.088261</td>\n",
       "      <td>-1.676805</td>\n",
       "      <td>-0.499672</td>\n",
       "      <td>-6.190970</td>\n",
       "      <td>1.106526</td>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-6.607001</td>\n",
       "      <td>-0.830714</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-03</th>\n",
       "      <td>5.214696</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>5.100982</td>\n",
       "      <td>-0.338631</td>\n",
       "      <td>-2.474351</td>\n",
       "      <td>-0.079196</td>\n",
       "      <td>-1.004275</td>\n",
       "      <td>...</td>\n",
       "      <td>-6.432081</td>\n",
       "      <td>0.886829</td>\n",
       "      <td>-1.292677</td>\n",
       "      <td>-5.525516</td>\n",
       "      <td>1.047210</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>-2.655326</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-04</th>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>4.476680</td>\n",
       "      <td>6.552588</td>\n",
       "      <td>0.376796</td>\n",
       "      <td>2.750829</td>\n",
       "      <td>-4.920712</td>\n",
       "      <td>...</td>\n",
       "      <td>1.493230</td>\n",
       "      <td>2.340617</td>\n",
       "      <td>-3.667713</td>\n",
       "      <td>-3.978552</td>\n",
       "      <td>2.339507</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-11.234331</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-05</th>\n",
       "      <td>0.257947</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>-2.378241</td>\n",
       "      <td>3.950870</td>\n",
       "      <td>5.929711</td>\n",
       "      <td>-1.906949</td>\n",
       "      <td>0.469008</td>\n",
       "      <td>...</td>\n",
       "      <td>-6.741424</td>\n",
       "      <td>-4.679552</td>\n",
       "      <td>-1.631346</td>\n",
       "      <td>1.761165</td>\n",
       "      <td>7.149424</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.185842</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-06</th>\n",
       "      <td>7.145218</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>2.835507</td>\n",
       "      <td>-1.358683</td>\n",
       "      <td>0.524880</td>\n",
       "      <td>-4.153961</td>\n",
       "      <td>2.942017</td>\n",
       "      <td>...</td>\n",
       "      <td>4.808590</td>\n",
       "      <td>-2.787980</td>\n",
       "      <td>3.516860</td>\n",
       "      <td>-4.689375</td>\n",
       "      <td>6.046229</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>-3.590396</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-30</th>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>-3.768885</td>\n",
       "      <td>-0.052595</td>\n",
       "      <td>4.300795</td>\n",
       "      <td>-3.456495</td>\n",
       "      <td>12.673751</td>\n",
       "      <td>...</td>\n",
       "      <td>-3.633627</td>\n",
       "      <td>9.913835</td>\n",
       "      <td>3.753404</td>\n",
       "      <td>2.270803</td>\n",
       "      <td>-4.408052</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.330415</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-03</th>\n",
       "      <td>-4.785395</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>1.462968</td>\n",
       "      <td>3.368377</td>\n",
       "      <td>1.780308</td>\n",
       "      <td>3.256101</td>\n",
       "      <td>3.142260</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.174710</td>\n",
       "      <td>-8.703934</td>\n",
       "      <td>0.358269</td>\n",
       "      <td>0.951083</td>\n",
       "      <td>7.093391</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>1.752599</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-04</th>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>5.956918</td>\n",
       "      <td>0.919193</td>\n",
       "      <td>-8.354800</td>\n",
       "      <td>7.583902</td>\n",
       "      <td>1.102699</td>\n",
       "      <td>...</td>\n",
       "      <td>-5.698807</td>\n",
       "      <td>1.147162</td>\n",
       "      <td>5.351075</td>\n",
       "      <td>-3.391325</td>\n",
       "      <td>3.285881</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>3.351110</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-05</th>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-2.222002</td>\n",
       "      <td>4.269999</td>\n",
       "      <td>5.187440</td>\n",
       "      <td>6.138300</td>\n",
       "      <td>-5.032291</td>\n",
       "      <td>...</td>\n",
       "      <td>1.566280</td>\n",
       "      <td>4.952497</td>\n",
       "      <td>-3.303121</td>\n",
       "      <td>-0.215049</td>\n",
       "      <td>0.747282</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>2.518201</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-12-06</th>\n",
       "      <td>-3.227615</td>\n",
       "      <td>-5.959835</td>\n",
       "      <td>4.681157</td>\n",
       "      <td>-4.754668</td>\n",
       "      <td>-0.331959</td>\n",
       "      <td>-0.270107</td>\n",
       "      <td>-0.701797</td>\n",
       "      <td>4.511615</td>\n",
       "      <td>4.768150</td>\n",
       "      <td>-6.451413</td>\n",
       "      <td>...</td>\n",
       "      <td>3.870776</td>\n",
       "      <td>-4.191871</td>\n",
       "      <td>-1.430710</td>\n",
       "      <td>0.040111</td>\n",
       "      <td>-2.326276</td>\n",
       "      <td>-1.801981</td>\n",
       "      <td>-4.740213</td>\n",
       "      <td>4.663355</td>\n",
       "      <td>-0.876057</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>504 rows × 500 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                 股票0       股票1       股票2       股票3       股票4       股票5  \\\n",
       "2017-01-02 -3.873053  0.284635  2.499973 -7.130197  2.757527 -2.395872   \n",
       "2017-01-03  5.214696 -2.624909  0.058714  5.386551  0.923505  5.100982   \n",
       "2017-01-04  0.968462  0.802624 -1.432836 -3.584072  1.065218  4.476680   \n",
       "2017-01-05  0.257947 -9.770720  3.467607 -5.698062  0.831143 -2.378241   \n",
       "2017-01-06  7.145218  1.286965  0.393309 -0.811168  2.161252  2.835507   \n",
       "...              ...       ...       ...       ...       ...       ...   \n",
       "2018-11-30 -2.537963 -2.158530 -2.505270  2.467084  0.656146 -3.768885   \n",
       "2018-12-03 -4.785395  2.319398  3.038020  8.437016  5.929354  1.462968   \n",
       "2018-12-04  4.387213 -1.932659  1.993627 -0.558287 -4.710914  5.956918   \n",
       "2018-12-05 -1.146364 -6.570785  3.922820 -5.979503  2.428449 -2.222002   \n",
       "2018-12-06 -3.227615 -5.959835  4.681157 -4.754668 -0.331959 -0.270107   \n",
       "\n",
       "                 股票6       股票7       股票8        股票9  ...     股票490     股票491  \\\n",
       "2017-01-02  0.358470  4.144862  2.890377  -6.015645  ...  0.285004  4.571598   \n",
       "2017-01-03 -0.338631 -2.474351 -0.079196  -1.004275  ... -6.432081  0.886829   \n",
       "2017-01-04  6.552588  0.376796  2.750829  -4.920712  ...  1.493230  2.340617   \n",
       "2017-01-05  3.950870  5.929711 -1.906949   0.469008  ... -6.741424 -4.679552   \n",
       "2017-01-06 -1.358683  0.524880 -4.153961   2.942017  ...  4.808590 -2.787980   \n",
       "...              ...       ...       ...        ...  ...       ...       ...   \n",
       "2018-11-30 -0.052595  4.300795 -3.456495  12.673751  ... -3.633627  9.913835   \n",
       "2018-12-03  3.368377  1.780308  3.256101   3.142260  ... -0.174710 -8.703934   \n",
       "2018-12-04  0.919193 -8.354800  7.583902   1.102699  ... -5.698807  1.147162   \n",
       "2018-12-05  4.269999  5.187440  6.138300  -5.032291  ...  1.566280  4.952497   \n",
       "2018-12-06 -0.701797  4.511615  4.768150  -6.451413  ...  3.870776 -4.191871   \n",
       "\n",
       "               股票492     股票493     股票494     股票495     股票496     股票497  \\\n",
       "2017-01-02  0.088261 -1.676805 -0.499672 -6.190970  1.106526 -0.537057   \n",
       "2017-01-03 -1.292677 -5.525516  1.047210 -8.096143 -1.860937 -4.222762   \n",
       "2017-01-04 -3.667713 -3.978552  2.339507  8.363273 -4.527927 -3.801068   \n",
       "2017-01-05 -1.631346  1.761165  7.149424  2.833073 -2.618610 -4.104841   \n",
       "2017-01-06  3.516860 -4.689375  6.046229  1.980141 -0.440584  3.296883   \n",
       "...              ...       ...       ...       ...       ...       ...   \n",
       "2018-11-30  3.753404  2.270803 -4.408052 -6.547008  0.773292 -1.677018   \n",
       "2018-12-03  0.358269  0.951083  7.093391 -1.069861  2.908074 -4.870802   \n",
       "2018-12-04  5.351075 -3.391325  3.285881  5.337184  7.449028 -3.923588   \n",
       "2018-12-05 -3.303121 -0.215049  0.747282  3.628220  0.732703 -0.164958   \n",
       "2018-12-06 -1.430710  0.040111 -2.326276 -1.801981 -4.740213  4.663355   \n",
       "\n",
       "               股票498      股票499  \n",
       "2017-01-02 -6.607001  -0.830714  \n",
       "2017-01-03  2.314433  -2.655326  \n",
       "2017-01-04  7.458581 -11.234331  \n",
       "2017-01-05 -7.153377  -0.185842  \n",
       "2017-01-06 -0.326586  -3.590396  \n",
       "...              ...        ...  \n",
       "2018-11-30 -2.209798  -1.330415  \n",
       "2018-12-03 -1.198215   1.752599  \n",
       "2018-12-04  3.361030   3.351110  \n",
       "2018-12-05 -8.903831   2.518201  \n",
       "2018-12-06 -0.876057  -4.141025  \n",
       "\n",
       "[504 rows x 500 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "missing-vienna",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票0</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票1</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票2</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票3</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票4</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票0   -3.873053    5.214696    0.968462    0.257947    7.145218    3.726503   \n",
       "股票1    0.284635   -2.624909    0.802624   -9.770720    1.286965    0.371357   \n",
       "股票2    2.499973    0.058714   -1.432836    3.467607    0.393309   -2.593841   \n",
       "股票3   -7.130197    5.386551   -3.584072   -5.698062   -0.811168   11.684473   \n",
       "股票4    2.757527    0.923505    1.065218    0.831143    2.161252    0.001553   \n",
       "\n",
       "     2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票0    0.048677    2.129644   -2.672674    1.997563  ...   -0.428511   \n",
       "股票1   -2.877826   -1.509765   -3.167601   -1.633638  ...    0.554594   \n",
       "股票2    2.718229   -1.129107   -2.780722   -6.705974  ...   -4.998007   \n",
       "股票3   -0.188643   -6.596933   10.824887   -2.422804  ...    0.995424   \n",
       "股票4    2.597266   -0.095404   -0.422169    1.093598  ...   -1.090444   \n",
       "\n",
       "     2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票0   -8.970102   -3.286372   -5.868192   -2.407854   -2.537963   -4.785395   \n",
       "股票1   -3.045685   -2.507414   -0.934476    2.114796   -2.158530    2.319398   \n",
       "股票2    1.183721   -2.565804    0.631494   10.390756   -2.505270    3.038020   \n",
       "股票3   -4.364533    1.279477   -2.123249   -1.379309    2.467084    8.437016   \n",
       "股票4    2.188031    5.767458   -1.034012    2.337551    0.656146    5.929354   \n",
       "\n",
       "     2018-12-04  2018-12-05  2018-12-06  \n",
       "股票0    4.387213   -1.146364   -3.227615  \n",
       "股票1   -1.932659   -6.570785   -5.959835  \n",
       "股票2    1.993627    3.922820    4.681157  \n",
       "股票3   -0.558287   -5.979503   -4.754668  \n",
       "股票4   -4.710914    2.428449   -0.331959  \n",
       "\n",
       "[5 rows x 504 columns]"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "curious-tender",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>股票490</th>\n",
       "      <td>0.285004</td>\n",
       "      <td>-6.432081</td>\n",
       "      <td>1.493230</td>\n",
       "      <td>-6.741424</td>\n",
       "      <td>4.808590</td>\n",
       "      <td>0.865218</td>\n",
       "      <td>5.791122</td>\n",
       "      <td>-0.083418</td>\n",
       "      <td>-1.052276</td>\n",
       "      <td>3.647824</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.652829</td>\n",
       "      <td>6.110496</td>\n",
       "      <td>5.919441</td>\n",
       "      <td>-1.403511</td>\n",
       "      <td>-5.812583</td>\n",
       "      <td>-3.633627</td>\n",
       "      <td>-0.174710</td>\n",
       "      <td>-5.698807</td>\n",
       "      <td>1.566280</td>\n",
       "      <td>3.870776</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票491</th>\n",
       "      <td>4.571598</td>\n",
       "      <td>0.886829</td>\n",
       "      <td>2.340617</td>\n",
       "      <td>-4.679552</td>\n",
       "      <td>-2.787980</td>\n",
       "      <td>-5.166826</td>\n",
       "      <td>6.114438</td>\n",
       "      <td>2.596742</td>\n",
       "      <td>7.526817</td>\n",
       "      <td>8.963395</td>\n",
       "      <td>...</td>\n",
       "      <td>-5.186541</td>\n",
       "      <td>4.410864</td>\n",
       "      <td>5.209072</td>\n",
       "      <td>-4.443844</td>\n",
       "      <td>5.079024</td>\n",
       "      <td>9.913835</td>\n",
       "      <td>-8.703934</td>\n",
       "      <td>1.147162</td>\n",
       "      <td>4.952497</td>\n",
       "      <td>-4.191871</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票492</th>\n",
       "      <td>0.088261</td>\n",
       "      <td>-1.292677</td>\n",
       "      <td>-3.667713</td>\n",
       "      <td>-1.631346</td>\n",
       "      <td>3.516860</td>\n",
       "      <td>1.066515</td>\n",
       "      <td>0.867011</td>\n",
       "      <td>1.908034</td>\n",
       "      <td>-1.692662</td>\n",
       "      <td>-1.838528</td>\n",
       "      <td>...</td>\n",
       "      <td>7.519024</td>\n",
       "      <td>-2.682846</td>\n",
       "      <td>1.546771</td>\n",
       "      <td>4.052896</td>\n",
       "      <td>0.445604</td>\n",
       "      <td>3.753404</td>\n",
       "      <td>0.358269</td>\n",
       "      <td>5.351075</td>\n",
       "      <td>-3.303121</td>\n",
       "      <td>-1.430710</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票493</th>\n",
       "      <td>-1.676805</td>\n",
       "      <td>-5.525516</td>\n",
       "      <td>-3.978552</td>\n",
       "      <td>1.761165</td>\n",
       "      <td>-4.689375</td>\n",
       "      <td>8.559686</td>\n",
       "      <td>3.537376</td>\n",
       "      <td>-8.969244</td>\n",
       "      <td>-4.893999</td>\n",
       "      <td>4.028358</td>\n",
       "      <td>...</td>\n",
       "      <td>8.875178</td>\n",
       "      <td>-0.947194</td>\n",
       "      <td>2.062792</td>\n",
       "      <td>0.969777</td>\n",
       "      <td>-1.503861</td>\n",
       "      <td>2.270803</td>\n",
       "      <td>0.951083</td>\n",
       "      <td>-3.391325</td>\n",
       "      <td>-0.215049</td>\n",
       "      <td>0.040111</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票494</th>\n",
       "      <td>-0.499672</td>\n",
       "      <td>1.047210</td>\n",
       "      <td>2.339507</td>\n",
       "      <td>7.149424</td>\n",
       "      <td>6.046229</td>\n",
       "      <td>-4.737671</td>\n",
       "      <td>-3.339456</td>\n",
       "      <td>7.501098</td>\n",
       "      <td>3.441156</td>\n",
       "      <td>-5.790812</td>\n",
       "      <td>...</td>\n",
       "      <td>4.375374</td>\n",
       "      <td>1.643408</td>\n",
       "      <td>-0.022731</td>\n",
       "      <td>-7.440980</td>\n",
       "      <td>-3.776444</td>\n",
       "      <td>-4.408052</td>\n",
       "      <td>7.093391</td>\n",
       "      <td>3.285881</td>\n",
       "      <td>0.747282</td>\n",
       "      <td>-2.326276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票495</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票496</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票497</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票498</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>股票499</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>10 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "       2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "股票490    0.285004   -6.432081    1.493230   -6.741424    4.808590    0.865218   \n",
       "股票491    4.571598    0.886829    2.340617   -4.679552   -2.787980   -5.166826   \n",
       "股票492    0.088261   -1.292677   -3.667713   -1.631346    3.516860    1.066515   \n",
       "股票493   -1.676805   -5.525516   -3.978552    1.761165   -4.689375    8.559686   \n",
       "股票494   -0.499672    1.047210    2.339507    7.149424    6.046229   -4.737671   \n",
       "股票495   -6.190970   -8.096143    8.363273    2.833073    1.980141   -1.983746   \n",
       "股票496    1.106526   -1.860937   -4.527927   -2.618610   -0.440584    0.284029   \n",
       "股票497   -0.537057   -4.222762   -3.801068   -4.104841    3.296883    6.116682   \n",
       "股票498   -6.607001    2.314433    7.458581   -7.153377   -0.326586    4.483198   \n",
       "股票499   -0.830714   -2.655326  -11.234331   -0.185842   -3.590396    1.095979   \n",
       "\n",
       "       2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "股票490    5.791122   -0.083418   -1.052276    3.647824  ...   -1.652829   \n",
       "股票491    6.114438    2.596742    7.526817    8.963395  ...   -5.186541   \n",
       "股票492    0.867011    1.908034   -1.692662   -1.838528  ...    7.519024   \n",
       "股票493    3.537376   -8.969244   -4.893999    4.028358  ...    8.875178   \n",
       "股票494   -3.339456    7.501098    3.441156   -5.790812  ...    4.375374   \n",
       "股票495   -2.724166   -1.070691   -2.610054   -1.646262  ...   -2.184017   \n",
       "股票496    1.474065   -7.136713   -0.717531   -4.495082  ...   -8.072072   \n",
       "股票497    4.286740   -8.228282   -6.515674   -0.261289  ...   -0.307919   \n",
       "股票498    2.086438   -4.955616    0.080462   -9.214175  ...    3.728769   \n",
       "股票499    2.130168   -5.170259    0.442787   -1.196191  ...    1.817441   \n",
       "\n",
       "       2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "股票490    6.110496    5.919441   -1.403511   -5.812583   -3.633627   -0.174710   \n",
       "股票491    4.410864    5.209072   -4.443844    5.079024    9.913835   -8.703934   \n",
       "股票492   -2.682846    1.546771    4.052896    0.445604    3.753404    0.358269   \n",
       "股票493   -0.947194    2.062792    0.969777   -1.503861    2.270803    0.951083   \n",
       "股票494    1.643408   -0.022731   -7.440980   -3.776444   -4.408052    7.093391   \n",
       "股票495    5.092414    1.600926    8.170517    4.310092   -6.547008   -1.069861   \n",
       "股票496    3.216294    3.585040    0.384871    4.979088    0.773292    2.908074   \n",
       "股票497    6.509931    1.805440    0.602975    4.177174   -1.677018   -4.870802   \n",
       "股票498   -0.799284   -2.611056   -2.263950    2.990817   -2.209798   -1.198215   \n",
       "股票499    3.433802   -9.659011    2.189575   -0.893896   -1.330415    1.752599   \n",
       "\n",
       "       2018-12-04  2018-12-05  2018-12-06  \n",
       "股票490   -5.698807    1.566280    3.870776  \n",
       "股票491    1.147162    4.952497   -4.191871  \n",
       "股票492    5.351075   -3.303121   -1.430710  \n",
       "股票493   -3.391325   -0.215049    0.040111  \n",
       "股票494    3.285881    0.747282   -2.326276  \n",
       "股票495    5.337184    3.628220   -1.801981  \n",
       "股票496    7.449028    0.732703   -4.740213  \n",
       "股票497   -3.923588   -0.164958    4.663355  \n",
       "股票498    3.361030   -8.903831   -0.876057  \n",
       "股票499    3.351110    2.518201   -4.141025  \n",
       "\n",
       "[10 rows x 504 columns]"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.tail(10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "perceived-heavy",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "Index does not support mutable operations",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-30-501cbef62ca3>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# 修改行列索引值\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mindex\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m499\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"0000001.SH\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36m__setitem__\u001b[1;34m(self, key, value)\u001b[0m\n\u001b[0;32m   4275\u001b[0m     \u001b[1;33m@\u001b[0m\u001b[0mfinal\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4276\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__setitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 4277\u001b[1;33m         \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Index does not support mutable operations\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   4278\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   4279\u001b[0m     \u001b[1;32mdef\u001b[0m \u001b[0m__getitem__\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mself\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: Index does not support mutable operations"
     ]
    }
   ],
   "source": [
    "# 修改行列索引值\n",
    "data.index[499] = \"0000001.SH\"   # 无法修改"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "sticky-receiver",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 通过整体修改，不能单个赋值\n",
    "data.index = [i+100 for i in range(500)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "directed-diving",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>595</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>596</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>597</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>598</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>599</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "100   -3.873053    5.214696    0.968462    0.257947    7.145218    3.726503   \n",
       "101    0.284635   -2.624909    0.802624   -9.770720    1.286965    0.371357   \n",
       "102    2.499973    0.058714   -1.432836    3.467607    0.393309   -2.593841   \n",
       "103   -7.130197    5.386551   -3.584072   -5.698062   -0.811168   11.684473   \n",
       "104    2.757527    0.923505    1.065218    0.831143    2.161252    0.001553   \n",
       "..          ...         ...         ...         ...         ...         ...   \n",
       "595   -6.190970   -8.096143    8.363273    2.833073    1.980141   -1.983746   \n",
       "596    1.106526   -1.860937   -4.527927   -2.618610   -0.440584    0.284029   \n",
       "597   -0.537057   -4.222762   -3.801068   -4.104841    3.296883    6.116682   \n",
       "598   -6.607001    2.314433    7.458581   -7.153377   -0.326586    4.483198   \n",
       "599   -0.830714   -2.655326  -11.234331   -0.185842   -3.590396    1.095979   \n",
       "\n",
       "     2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "100    0.048677    2.129644   -2.672674    1.997563  ...   -0.428511   \n",
       "101   -2.877826   -1.509765   -3.167601   -1.633638  ...    0.554594   \n",
       "102    2.718229   -1.129107   -2.780722   -6.705974  ...   -4.998007   \n",
       "103   -0.188643   -6.596933   10.824887   -2.422804  ...    0.995424   \n",
       "104    2.597266   -0.095404   -0.422169    1.093598  ...   -1.090444   \n",
       "..          ...         ...         ...         ...  ...         ...   \n",
       "595   -2.724166   -1.070691   -2.610054   -1.646262  ...   -2.184017   \n",
       "596    1.474065   -7.136713   -0.717531   -4.495082  ...   -8.072072   \n",
       "597    4.286740   -8.228282   -6.515674   -0.261289  ...   -0.307919   \n",
       "598    2.086438   -4.955616    0.080462   -9.214175  ...    3.728769   \n",
       "599    2.130168   -5.170259    0.442787   -1.196191  ...    1.817441   \n",
       "\n",
       "     2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "100   -8.970102   -3.286372   -5.868192   -2.407854   -2.537963   -4.785395   \n",
       "101   -3.045685   -2.507414   -0.934476    2.114796   -2.158530    2.319398   \n",
       "102    1.183721   -2.565804    0.631494   10.390756   -2.505270    3.038020   \n",
       "103   -4.364533    1.279477   -2.123249   -1.379309    2.467084    8.437016   \n",
       "104    2.188031    5.767458   -1.034012    2.337551    0.656146    5.929354   \n",
       "..          ...         ...         ...         ...         ...         ...   \n",
       "595    5.092414    1.600926    8.170517    4.310092   -6.547008   -1.069861   \n",
       "596    3.216294    3.585040    0.384871    4.979088    0.773292    2.908074   \n",
       "597    6.509931    1.805440    0.602975    4.177174   -1.677018   -4.870802   \n",
       "598   -0.799284   -2.611056   -2.263950    2.990817   -2.209798   -1.198215   \n",
       "599    3.433802   -9.659011    2.189575   -0.893896   -1.330415    1.752599   \n",
       "\n",
       "     2018-12-04  2018-12-05  2018-12-06  \n",
       "100    4.387213   -1.146364   -3.227615  \n",
       "101   -1.932659   -6.570785   -5.959835  \n",
       "102    1.993627    3.922820    4.681157  \n",
       "103   -0.558287   -5.979503   -4.754668  \n",
       "104   -4.710914    2.428449   -0.331959  \n",
       "..          ...         ...         ...  \n",
       "595    5.337184    3.628220   -1.801981  \n",
       "596    7.449028    0.732703   -4.740213  \n",
       "597   -3.923588   -0.164958    4.663355  \n",
       "598    3.361030   -8.903831   -0.876057  \n",
       "599    3.351110    2.518201   -4.141025  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "productive-porcelain",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>index</th>\n",
       "      <th>2017-01-02 00:00:00</th>\n",
       "      <th>2017-01-03 00:00:00</th>\n",
       "      <th>2017-01-04 00:00:00</th>\n",
       "      <th>2017-01-05 00:00:00</th>\n",
       "      <th>2017-01-06 00:00:00</th>\n",
       "      <th>2017-01-09 00:00:00</th>\n",
       "      <th>2017-01-10 00:00:00</th>\n",
       "      <th>2017-01-11 00:00:00</th>\n",
       "      <th>2017-01-12 00:00:00</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23 00:00:00</th>\n",
       "      <th>2018-11-26 00:00:00</th>\n",
       "      <th>2018-11-27 00:00:00</th>\n",
       "      <th>2018-11-28 00:00:00</th>\n",
       "      <th>2018-11-29 00:00:00</th>\n",
       "      <th>2018-11-30 00:00:00</th>\n",
       "      <th>2018-12-03 00:00:00</th>\n",
       "      <th>2018-12-04 00:00:00</th>\n",
       "      <th>2018-12-05 00:00:00</th>\n",
       "      <th>2018-12-06 00:00:00</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100</td>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>101</td>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>102</td>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>103</td>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>104</td>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>495</th>\n",
       "      <td>595</td>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>496</th>\n",
       "      <td>596</td>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>497</th>\n",
       "      <td>597</td>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>498</th>\n",
       "      <td>598</td>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>499</th>\n",
       "      <td>599</td>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 505 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     index  2017-01-02 00:00:00  2017-01-03 00:00:00  2017-01-04 00:00:00  \\\n",
       "0      100            -3.873053             5.214696             0.968462   \n",
       "1      101             0.284635            -2.624909             0.802624   \n",
       "2      102             2.499973             0.058714            -1.432836   \n",
       "3      103            -7.130197             5.386551            -3.584072   \n",
       "4      104             2.757527             0.923505             1.065218   \n",
       "..     ...                  ...                  ...                  ...   \n",
       "495    595            -6.190970            -8.096143             8.363273   \n",
       "496    596             1.106526            -1.860937            -4.527927   \n",
       "497    597            -0.537057            -4.222762            -3.801068   \n",
       "498    598            -6.607001             2.314433             7.458581   \n",
       "499    599            -0.830714            -2.655326           -11.234331   \n",
       "\n",
       "     2017-01-05 00:00:00  2017-01-06 00:00:00  2017-01-09 00:00:00  \\\n",
       "0               0.257947             7.145218             3.726503   \n",
       "1              -9.770720             1.286965             0.371357   \n",
       "2               3.467607             0.393309            -2.593841   \n",
       "3              -5.698062            -0.811168            11.684473   \n",
       "4               0.831143             2.161252             0.001553   \n",
       "..                   ...                  ...                  ...   \n",
       "495             2.833073             1.980141            -1.983746   \n",
       "496            -2.618610            -0.440584             0.284029   \n",
       "497            -4.104841             3.296883             6.116682   \n",
       "498            -7.153377            -0.326586             4.483198   \n",
       "499            -0.185842            -3.590396             1.095979   \n",
       "\n",
       "     2017-01-10 00:00:00  2017-01-11 00:00:00  2017-01-12 00:00:00  ...  \\\n",
       "0               0.048677             2.129644            -2.672674  ...   \n",
       "1              -2.877826            -1.509765            -3.167601  ...   \n",
       "2               2.718229            -1.129107            -2.780722  ...   \n",
       "3              -0.188643            -6.596933            10.824887  ...   \n",
       "4               2.597266            -0.095404            -0.422169  ...   \n",
       "..                   ...                  ...                  ...  ...   \n",
       "495            -2.724166            -1.070691            -2.610054  ...   \n",
       "496             1.474065            -7.136713            -0.717531  ...   \n",
       "497             4.286740            -8.228282            -6.515674  ...   \n",
       "498             2.086438            -4.955616             0.080462  ...   \n",
       "499             2.130168            -5.170259             0.442787  ...   \n",
       "\n",
       "     2018-11-23 00:00:00  2018-11-26 00:00:00  2018-11-27 00:00:00  \\\n",
       "0              -0.428511            -8.970102            -3.286372   \n",
       "1               0.554594            -3.045685            -2.507414   \n",
       "2              -4.998007             1.183721            -2.565804   \n",
       "3               0.995424            -4.364533             1.279477   \n",
       "4              -1.090444             2.188031             5.767458   \n",
       "..                   ...                  ...                  ...   \n",
       "495            -2.184017             5.092414             1.600926   \n",
       "496            -8.072072             3.216294             3.585040   \n",
       "497            -0.307919             6.509931             1.805440   \n",
       "498             3.728769            -0.799284            -2.611056   \n",
       "499             1.817441             3.433802            -9.659011   \n",
       "\n",
       "     2018-11-28 00:00:00  2018-11-29 00:00:00  2018-11-30 00:00:00  \\\n",
       "0              -5.868192            -2.407854            -2.537963   \n",
       "1              -0.934476             2.114796            -2.158530   \n",
       "2               0.631494            10.390756            -2.505270   \n",
       "3              -2.123249            -1.379309             2.467084   \n",
       "4              -1.034012             2.337551             0.656146   \n",
       "..                   ...                  ...                  ...   \n",
       "495             8.170517             4.310092            -6.547008   \n",
       "496             0.384871             4.979088             0.773292   \n",
       "497             0.602975             4.177174            -1.677018   \n",
       "498            -2.263950             2.990817            -2.209798   \n",
       "499             2.189575            -0.893896            -1.330415   \n",
       "\n",
       "     2018-12-03 00:00:00  2018-12-04 00:00:00  2018-12-05 00:00:00  \\\n",
       "0              -4.785395             4.387213            -1.146364   \n",
       "1               2.319398            -1.932659            -6.570785   \n",
       "2               3.038020             1.993627             3.922820   \n",
       "3               8.437016            -0.558287            -5.979503   \n",
       "4               5.929354            -4.710914             2.428449   \n",
       "..                   ...                  ...                  ...   \n",
       "495            -1.069861             5.337184             3.628220   \n",
       "496             2.908074             7.449028             0.732703   \n",
       "497            -4.870802            -3.923588            -0.164958   \n",
       "498            -1.198215             3.361030            -8.903831   \n",
       "499             1.752599             3.351110             2.518201   \n",
       "\n",
       "     2018-12-06 00:00:00  \n",
       "0              -3.227615  \n",
       "1              -5.959835  \n",
       "2               4.681157  \n",
       "3              -4.754668  \n",
       "4              -0.331959  \n",
       "..                   ...  \n",
       "495            -1.801981  \n",
       "496            -4.740213  \n",
       "497             4.663355  \n",
       "498            -0.876057  \n",
       "499            -4.141025  \n",
       "\n",
       "[500 rows x 505 columns]"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 重置索引\n",
    "data.reset_index(drop=False)   # drop是否丢弃索引，如果为false则将索引保留为一列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "missing-discharge",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   month  year  sale\n",
       "0      1     1    55\n",
       "1      4     1    40\n",
       "2      7     2    84\n",
       "3     10     2    31"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({'month':[1,4,7,10], 'year':[1, 1, 2, 2], 'sale':[55, 40, 84, 31]})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "funky-psychology",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       year  sale\n",
       "month            \n",
       "1         1    55\n",
       "4         1    40\n",
       "7         2    84\n",
       "10        2    31"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# df.set_index(['month'])# 设置新的索引值，但是返回一个新的dataframe\n",
    "df = df.set_index(['month'])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "institutional-original",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>year</th>\n",
       "      <th>month</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">1</th>\n",
       "      <th>1</th>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th rowspan=\"2\" valign=\"top\">2</th>\n",
       "      <th>7</th>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            sale\n",
       "year month      \n",
       "1    1        55\n",
       "     4        40\n",
       "2    7        84\n",
       "     10       31"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 设置多重索引 MultiIndex的结构\n",
    "df = df.set_index(['year', df.index])\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "wrapped-coordinate",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2017-01-02</th>\n",
       "      <th>2017-01-03</th>\n",
       "      <th>2017-01-04</th>\n",
       "      <th>2017-01-05</th>\n",
       "      <th>2017-01-06</th>\n",
       "      <th>2017-01-09</th>\n",
       "      <th>2017-01-10</th>\n",
       "      <th>2017-01-11</th>\n",
       "      <th>2017-01-12</th>\n",
       "      <th>2017-01-13</th>\n",
       "      <th>...</th>\n",
       "      <th>2018-11-23</th>\n",
       "      <th>2018-11-26</th>\n",
       "      <th>2018-11-27</th>\n",
       "      <th>2018-11-28</th>\n",
       "      <th>2018-11-29</th>\n",
       "      <th>2018-11-30</th>\n",
       "      <th>2018-12-03</th>\n",
       "      <th>2018-12-04</th>\n",
       "      <th>2018-12-05</th>\n",
       "      <th>2018-12-06</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>100</th>\n",
       "      <td>-3.873053</td>\n",
       "      <td>5.214696</td>\n",
       "      <td>0.968462</td>\n",
       "      <td>0.257947</td>\n",
       "      <td>7.145218</td>\n",
       "      <td>3.726503</td>\n",
       "      <td>0.048677</td>\n",
       "      <td>2.129644</td>\n",
       "      <td>-2.672674</td>\n",
       "      <td>1.997563</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.428511</td>\n",
       "      <td>-8.970102</td>\n",
       "      <td>-3.286372</td>\n",
       "      <td>-5.868192</td>\n",
       "      <td>-2.407854</td>\n",
       "      <td>-2.537963</td>\n",
       "      <td>-4.785395</td>\n",
       "      <td>4.387213</td>\n",
       "      <td>-1.146364</td>\n",
       "      <td>-3.227615</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>101</th>\n",
       "      <td>0.284635</td>\n",
       "      <td>-2.624909</td>\n",
       "      <td>0.802624</td>\n",
       "      <td>-9.770720</td>\n",
       "      <td>1.286965</td>\n",
       "      <td>0.371357</td>\n",
       "      <td>-2.877826</td>\n",
       "      <td>-1.509765</td>\n",
       "      <td>-3.167601</td>\n",
       "      <td>-1.633638</td>\n",
       "      <td>...</td>\n",
       "      <td>0.554594</td>\n",
       "      <td>-3.045685</td>\n",
       "      <td>-2.507414</td>\n",
       "      <td>-0.934476</td>\n",
       "      <td>2.114796</td>\n",
       "      <td>-2.158530</td>\n",
       "      <td>2.319398</td>\n",
       "      <td>-1.932659</td>\n",
       "      <td>-6.570785</td>\n",
       "      <td>-5.959835</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>102</th>\n",
       "      <td>2.499973</td>\n",
       "      <td>0.058714</td>\n",
       "      <td>-1.432836</td>\n",
       "      <td>3.467607</td>\n",
       "      <td>0.393309</td>\n",
       "      <td>-2.593841</td>\n",
       "      <td>2.718229</td>\n",
       "      <td>-1.129107</td>\n",
       "      <td>-2.780722</td>\n",
       "      <td>-6.705974</td>\n",
       "      <td>...</td>\n",
       "      <td>-4.998007</td>\n",
       "      <td>1.183721</td>\n",
       "      <td>-2.565804</td>\n",
       "      <td>0.631494</td>\n",
       "      <td>10.390756</td>\n",
       "      <td>-2.505270</td>\n",
       "      <td>3.038020</td>\n",
       "      <td>1.993627</td>\n",
       "      <td>3.922820</td>\n",
       "      <td>4.681157</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>103</th>\n",
       "      <td>-7.130197</td>\n",
       "      <td>5.386551</td>\n",
       "      <td>-3.584072</td>\n",
       "      <td>-5.698062</td>\n",
       "      <td>-0.811168</td>\n",
       "      <td>11.684473</td>\n",
       "      <td>-0.188643</td>\n",
       "      <td>-6.596933</td>\n",
       "      <td>10.824887</td>\n",
       "      <td>-2.422804</td>\n",
       "      <td>...</td>\n",
       "      <td>0.995424</td>\n",
       "      <td>-4.364533</td>\n",
       "      <td>1.279477</td>\n",
       "      <td>-2.123249</td>\n",
       "      <td>-1.379309</td>\n",
       "      <td>2.467084</td>\n",
       "      <td>8.437016</td>\n",
       "      <td>-0.558287</td>\n",
       "      <td>-5.979503</td>\n",
       "      <td>-4.754668</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>104</th>\n",
       "      <td>2.757527</td>\n",
       "      <td>0.923505</td>\n",
       "      <td>1.065218</td>\n",
       "      <td>0.831143</td>\n",
       "      <td>2.161252</td>\n",
       "      <td>0.001553</td>\n",
       "      <td>2.597266</td>\n",
       "      <td>-0.095404</td>\n",
       "      <td>-0.422169</td>\n",
       "      <td>1.093598</td>\n",
       "      <td>...</td>\n",
       "      <td>-1.090444</td>\n",
       "      <td>2.188031</td>\n",
       "      <td>5.767458</td>\n",
       "      <td>-1.034012</td>\n",
       "      <td>2.337551</td>\n",
       "      <td>0.656146</td>\n",
       "      <td>5.929354</td>\n",
       "      <td>-4.710914</td>\n",
       "      <td>2.428449</td>\n",
       "      <td>-0.331959</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>595</th>\n",
       "      <td>-6.190970</td>\n",
       "      <td>-8.096143</td>\n",
       "      <td>8.363273</td>\n",
       "      <td>2.833073</td>\n",
       "      <td>1.980141</td>\n",
       "      <td>-1.983746</td>\n",
       "      <td>-2.724166</td>\n",
       "      <td>-1.070691</td>\n",
       "      <td>-2.610054</td>\n",
       "      <td>-1.646262</td>\n",
       "      <td>...</td>\n",
       "      <td>-2.184017</td>\n",
       "      <td>5.092414</td>\n",
       "      <td>1.600926</td>\n",
       "      <td>8.170517</td>\n",
       "      <td>4.310092</td>\n",
       "      <td>-6.547008</td>\n",
       "      <td>-1.069861</td>\n",
       "      <td>5.337184</td>\n",
       "      <td>3.628220</td>\n",
       "      <td>-1.801981</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>596</th>\n",
       "      <td>1.106526</td>\n",
       "      <td>-1.860937</td>\n",
       "      <td>-4.527927</td>\n",
       "      <td>-2.618610</td>\n",
       "      <td>-0.440584</td>\n",
       "      <td>0.284029</td>\n",
       "      <td>1.474065</td>\n",
       "      <td>-7.136713</td>\n",
       "      <td>-0.717531</td>\n",
       "      <td>-4.495082</td>\n",
       "      <td>...</td>\n",
       "      <td>-8.072072</td>\n",
       "      <td>3.216294</td>\n",
       "      <td>3.585040</td>\n",
       "      <td>0.384871</td>\n",
       "      <td>4.979088</td>\n",
       "      <td>0.773292</td>\n",
       "      <td>2.908074</td>\n",
       "      <td>7.449028</td>\n",
       "      <td>0.732703</td>\n",
       "      <td>-4.740213</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>597</th>\n",
       "      <td>-0.537057</td>\n",
       "      <td>-4.222762</td>\n",
       "      <td>-3.801068</td>\n",
       "      <td>-4.104841</td>\n",
       "      <td>3.296883</td>\n",
       "      <td>6.116682</td>\n",
       "      <td>4.286740</td>\n",
       "      <td>-8.228282</td>\n",
       "      <td>-6.515674</td>\n",
       "      <td>-0.261289</td>\n",
       "      <td>...</td>\n",
       "      <td>-0.307919</td>\n",
       "      <td>6.509931</td>\n",
       "      <td>1.805440</td>\n",
       "      <td>0.602975</td>\n",
       "      <td>4.177174</td>\n",
       "      <td>-1.677018</td>\n",
       "      <td>-4.870802</td>\n",
       "      <td>-3.923588</td>\n",
       "      <td>-0.164958</td>\n",
       "      <td>4.663355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>598</th>\n",
       "      <td>-6.607001</td>\n",
       "      <td>2.314433</td>\n",
       "      <td>7.458581</td>\n",
       "      <td>-7.153377</td>\n",
       "      <td>-0.326586</td>\n",
       "      <td>4.483198</td>\n",
       "      <td>2.086438</td>\n",
       "      <td>-4.955616</td>\n",
       "      <td>0.080462</td>\n",
       "      <td>-9.214175</td>\n",
       "      <td>...</td>\n",
       "      <td>3.728769</td>\n",
       "      <td>-0.799284</td>\n",
       "      <td>-2.611056</td>\n",
       "      <td>-2.263950</td>\n",
       "      <td>2.990817</td>\n",
       "      <td>-2.209798</td>\n",
       "      <td>-1.198215</td>\n",
       "      <td>3.361030</td>\n",
       "      <td>-8.903831</td>\n",
       "      <td>-0.876057</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>599</th>\n",
       "      <td>-0.830714</td>\n",
       "      <td>-2.655326</td>\n",
       "      <td>-11.234331</td>\n",
       "      <td>-0.185842</td>\n",
       "      <td>-3.590396</td>\n",
       "      <td>1.095979</td>\n",
       "      <td>2.130168</td>\n",
       "      <td>-5.170259</td>\n",
       "      <td>0.442787</td>\n",
       "      <td>-1.196191</td>\n",
       "      <td>...</td>\n",
       "      <td>1.817441</td>\n",
       "      <td>3.433802</td>\n",
       "      <td>-9.659011</td>\n",
       "      <td>2.189575</td>\n",
       "      <td>-0.893896</td>\n",
       "      <td>-1.330415</td>\n",
       "      <td>1.752599</td>\n",
       "      <td>3.351110</td>\n",
       "      <td>2.518201</td>\n",
       "      <td>-4.141025</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>500 rows × 504 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     2017-01-02  2017-01-03  2017-01-04  2017-01-05  2017-01-06  2017-01-09  \\\n",
       "100   -3.873053    5.214696    0.968462    0.257947    7.145218    3.726503   \n",
       "101    0.284635   -2.624909    0.802624   -9.770720    1.286965    0.371357   \n",
       "102    2.499973    0.058714   -1.432836    3.467607    0.393309   -2.593841   \n",
       "103   -7.130197    5.386551   -3.584072   -5.698062   -0.811168   11.684473   \n",
       "104    2.757527    0.923505    1.065218    0.831143    2.161252    0.001553   \n",
       "..          ...         ...         ...         ...         ...         ...   \n",
       "595   -6.190970   -8.096143    8.363273    2.833073    1.980141   -1.983746   \n",
       "596    1.106526   -1.860937   -4.527927   -2.618610   -0.440584    0.284029   \n",
       "597   -0.537057   -4.222762   -3.801068   -4.104841    3.296883    6.116682   \n",
       "598   -6.607001    2.314433    7.458581   -7.153377   -0.326586    4.483198   \n",
       "599   -0.830714   -2.655326  -11.234331   -0.185842   -3.590396    1.095979   \n",
       "\n",
       "     2017-01-10  2017-01-11  2017-01-12  2017-01-13  ...  2018-11-23  \\\n",
       "100    0.048677    2.129644   -2.672674    1.997563  ...   -0.428511   \n",
       "101   -2.877826   -1.509765   -3.167601   -1.633638  ...    0.554594   \n",
       "102    2.718229   -1.129107   -2.780722   -6.705974  ...   -4.998007   \n",
       "103   -0.188643   -6.596933   10.824887   -2.422804  ...    0.995424   \n",
       "104    2.597266   -0.095404   -0.422169    1.093598  ...   -1.090444   \n",
       "..          ...         ...         ...         ...  ...         ...   \n",
       "595   -2.724166   -1.070691   -2.610054   -1.646262  ...   -2.184017   \n",
       "596    1.474065   -7.136713   -0.717531   -4.495082  ...   -8.072072   \n",
       "597    4.286740   -8.228282   -6.515674   -0.261289  ...   -0.307919   \n",
       "598    2.086438   -4.955616    0.080462   -9.214175  ...    3.728769   \n",
       "599    2.130168   -5.170259    0.442787   -1.196191  ...    1.817441   \n",
       "\n",
       "     2018-11-26  2018-11-27  2018-11-28  2018-11-29  2018-11-30  2018-12-03  \\\n",
       "100   -8.970102   -3.286372   -5.868192   -2.407854   -2.537963   -4.785395   \n",
       "101   -3.045685   -2.507414   -0.934476    2.114796   -2.158530    2.319398   \n",
       "102    1.183721   -2.565804    0.631494   10.390756   -2.505270    3.038020   \n",
       "103   -4.364533    1.279477   -2.123249   -1.379309    2.467084    8.437016   \n",
       "104    2.188031    5.767458   -1.034012    2.337551    0.656146    5.929354   \n",
       "..          ...         ...         ...         ...         ...         ...   \n",
       "595    5.092414    1.600926    8.170517    4.310092   -6.547008   -1.069861   \n",
       "596    3.216294    3.585040    0.384871    4.979088    0.773292    2.908074   \n",
       "597    6.509931    1.805440    0.602975    4.177174   -1.677018   -4.870802   \n",
       "598   -0.799284   -2.611056   -2.263950    2.990817   -2.209798   -1.198215   \n",
       "599    3.433802   -9.659011    2.189575   -0.893896   -1.330415    1.752599   \n",
       "\n",
       "     2018-12-04  2018-12-05  2018-12-06  \n",
       "100    4.387213   -1.146364   -3.227615  \n",
       "101   -1.932659   -6.570785   -5.959835  \n",
       "102    1.993627    3.922820    4.681157  \n",
       "103   -0.558287   -5.979503   -4.754668  \n",
       "104   -4.710914    2.428449   -0.331959  \n",
       "..          ...         ...         ...  \n",
       "595    5.337184    3.628220   -1.801981  \n",
       "596    7.449028    0.732703   -4.740213  \n",
       "597   -3.923588   -0.164958    4.663355  \n",
       "598    3.361030   -8.903831   -0.876057  \n",
       "599    3.351110    2.518201   -4.141025  \n",
       "\n",
       "[500 rows x 504 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "dress-crest",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "-3.873052863620057"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['2017-01-02'][100]    # pandas取数据是先  列 再行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "geographic-polymer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "股票0    0\n",
       "股票1    1\n",
       "股票2    2\n",
       "股票3    3\n",
       "股票4    4\n",
       "股票5    5\n",
       "股票6    6\n",
       "股票7    7\n",
       "股票8    8\n",
       "股票9    9\n",
       "dtype: int32"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(np.arange(10),index=[\"股票\"+str(i) for i in range(10)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "tested-smart",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "red        100\n",
       "blue       200\n",
       "green      500\n",
       "yellow    1000\n",
       "dtype: int64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se = pd.Series({'red':100, 'blue':200, 'green': 500, 'yellow':1000})\n",
    "se"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "stuffed-growth",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['red', 'blue', 'green', 'yellow'], dtype='object')"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "rapid-assembly",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 100,  200,  500, 1000], dtype=int64)"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "se.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "hybrid-blues",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "removed-meaning",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'F:\\\\龙坡\\\\代码\\\\ai2021\\\\移动2031'"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.getcwd()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "smoking-catalog",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 读取文件\n",
    "data = pd.read_csv(\"./data/stock_day.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "whole-chicago",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>14.28</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>13.16</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>12.90</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>12.70</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.52</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53   95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80   60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71   52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02   36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48   23331.04          0.44      2.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  13.17  14.48  14.28  13.13  179831.72          1.12      8.51   \n",
       "2015-03-05  12.88  13.45  13.16  12.87   93180.39          0.26      2.02   \n",
       "2015-03-04  12.80  12.92  12.90  12.61   67075.44          0.20      1.57   \n",
       "2015-03-03  12.52  13.06  12.70  12.52  139071.61          0.18      1.44   \n",
       "2015-03-02  12.25  12.67  12.52  12.20   96291.73          0.32      2.62   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "innovative-festival",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'2018-02-27'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3079\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3080\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '2018-02-27'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-5-982a9db4d7d6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdata\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'2018-02-27'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'open'\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   3022\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3023\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3024\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3025\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3026\u001b[0m                 \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mC:\\ProgramData\\Anaconda3\\envs\\tf20\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3080\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3082\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3083\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3084\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mtolerance\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '2018-02-27'"
     ]
    }
   ],
   "source": [
    "data['2018-02-27']['open']   # 错误"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "small-intro",
   "metadata": {},
   "source": [
    "### 索引与切片\n",
    "* 直接使用行列索引(先列后行)\n",
    "* 结合loc或者iloc使用索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "changing-machine",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "23.53"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['open']['2018-02-27']   # pandas取数据是先列后行   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "cubic-demonstration",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['open'][['2018-02-27']]   # 上面这个叫取数据， 下面叫切片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "motivated-decimal",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['open'][ ['2018-02-27'] ]    # 花式索引  切片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "documented-enlargement",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-27    23.53\n",
       "2018-02-26    22.80\n",
       "2018-02-23    22.88\n",
       "2018-02-22    22.25\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用loc\n",
    "# loc:只能指定行列索引的名字\n",
    "data.loc['2018-02-27':'2018-02-22', 'open']   # 用loc 可以先行后列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "harmful-pattern",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2018-02-22    22.25\n",
       "2018-02-23    22.88\n",
       "2018-02-26    22.80\n",
       "2018-02-27    23.53\n",
       "Name: open, dtype: float64"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.loc['2018-02-22':'2018-02-27':-1, 'open']   # 用loc 可以先行后列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "norman-schedule",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53  95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80  60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71  52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02  36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48  23331.04          0.44      2.05   \n",
       "\n",
       "               ma5    ma10    ma20     v_ma5    v_ma10    v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875  53782.64  46738.65  55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942  40827.52  42736.34  56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022  35119.58  41871.97  56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137  35397.58  39904.78  60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253  33590.21  42935.74  61716.11      0.58  "
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "starting-moderator",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high\n",
       "2018-02-27  23.53  25.88\n",
       "2018-02-26  22.80  23.78\n",
       "2018-02-23  22.88  23.37\n",
       "2018-02-22  22.25  22.76\n",
       "2018-02-14  21.49  21.99"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 使用iloc\n",
    "# 使用iloc可以通过索引的下标去获取   iloc == index location\n",
    "data.iloc[0:100, 0:2].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "biological-personality",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53  95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80  60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71  52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02  36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48  23331.04          0.44      2.05   \n",
       "\n",
       "               ma5    ma10    ma20     v_ma5    v_ma10    v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875  53782.64  46738.65  55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942  40827.52  42736.34  56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022  35119.58  41871.97  56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137  35397.58  39904.78  60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253  33590.21  42935.74  61716.11      0.58  "
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "original-former",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['close'] = 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "postal-minute",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>1</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88      1  23.53  95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78      1  22.80  60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37      1  22.71  52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76      1  22.02  36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99      1  21.48  23331.04          0.44      2.05   \n",
       "\n",
       "               ma5    ma10    ma20     v_ma5    v_ma10    v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875  53782.64  46738.65  55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942  40827.52  42736.34  56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022  35119.58  41871.97  56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137  35397.58  39904.78  60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253  33590.21  42935.74  61716.11      0.58  "
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "internal-savannah",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "<ipython-input-30-cf550e2e401d>:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  data['close']['2018-02-26'] = 10\n"
     ]
    }
   ],
   "source": [
    "data['close']['2018-02-26'] = 10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "upper-singer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>10</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low    volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88      1  23.53  95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78     10  22.80  60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37      1  22.71  52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76      1  22.02  36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99      1  21.48  23331.04          0.44      2.05   \n",
       "\n",
       "               ma5    ma10    ma20     v_ma5    v_ma10    v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875  53782.64  46738.65  55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942  40827.52  42736.34  56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022  35119.58  41871.97  56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137  35397.58  39904.78  60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253  33590.21  42935.74  61716.11      0.58  "
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "architectural-organization",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-08-28</th>\n",
       "      <td>15.40</td>\n",
       "      <td>16.46</td>\n",
       "      <td>1</td>\n",
       "      <td>15.00</td>\n",
       "      <td>117827.60</td>\n",
       "      <td>1.50</td>\n",
       "      <td>10.03</td>\n",
       "      <td>16.698</td>\n",
       "      <td>18.849</td>\n",
       "      <td>18.853</td>\n",
       "      <td>92680.85</td>\n",
       "      <td>109609.73</td>\n",
       "      <td>107384.89</td>\n",
       "      <td>4.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-21</th>\n",
       "      <td>27.50</td>\n",
       "      <td>28.22</td>\n",
       "      <td>1</td>\n",
       "      <td>26.50</td>\n",
       "      <td>121190.11</td>\n",
       "      <td>2.57</td>\n",
       "      <td>10.02</td>\n",
       "      <td>24.508</td>\n",
       "      <td>22.725</td>\n",
       "      <td>22.053</td>\n",
       "      <td>117760.48</td>\n",
       "      <td>103865.87</td>\n",
       "      <td>98766.20</td>\n",
       "      <td>4.15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-22</th>\n",
       "      <td>18.50</td>\n",
       "      <td>20.42</td>\n",
       "      <td>1</td>\n",
       "      <td>18.45</td>\n",
       "      <td>150470.83</td>\n",
       "      <td>1.86</td>\n",
       "      <td>10.02</td>\n",
       "      <td>18.874</td>\n",
       "      <td>18.775</td>\n",
       "      <td>20.455</td>\n",
       "      <td>59074.51</td>\n",
       "      <td>77760.81</td>\n",
       "      <td>74734.64</td>\n",
       "      <td>3.77</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-08-04</th>\n",
       "      <td>16.20</td>\n",
       "      <td>17.35</td>\n",
       "      <td>1</td>\n",
       "      <td>15.80</td>\n",
       "      <td>94292.63</td>\n",
       "      <td>1.58</td>\n",
       "      <td>10.02</td>\n",
       "      <td>17.736</td>\n",
       "      <td>19.765</td>\n",
       "      <td>21.454</td>\n",
       "      <td>87169.08</td>\n",
       "      <td>104549.78</td>\n",
       "      <td>123074.95</td>\n",
       "      <td>3.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-07-07</th>\n",
       "      <td>18.66</td>\n",
       "      <td>18.66</td>\n",
       "      <td>1</td>\n",
       "      <td>18.41</td>\n",
       "      <td>48756.55</td>\n",
       "      <td>1.70</td>\n",
       "      <td>10.02</td>\n",
       "      <td>16.206</td>\n",
       "      <td>15.768</td>\n",
       "      <td>15.639</td>\n",
       "      <td>25103.33</td>\n",
       "      <td>30923.60</td>\n",
       "      <td>38378.63</td>\n",
       "      <td>1.67</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-08-26</th>\n",
       "      <td>17.00</td>\n",
       "      <td>18.35</td>\n",
       "      <td>1</td>\n",
       "      <td>15.56</td>\n",
       "      <td>130318.31</td>\n",
       "      <td>-1.73</td>\n",
       "      <td>-10.01</td>\n",
       "      <td>18.742</td>\n",
       "      <td>20.042</td>\n",
       "      <td>19.087</td>\n",
       "      <td>100097.45</td>\n",
       "      <td>114432.06</td>\n",
       "      <td>102945.90</td>\n",
       "      <td>4.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-07-15</th>\n",
       "      <td>22.78</td>\n",
       "      <td>23.04</td>\n",
       "      <td>1</td>\n",
       "      <td>22.10</td>\n",
       "      <td>85966.42</td>\n",
       "      <td>-2.46</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>24.564</td>\n",
       "      <td>25.197</td>\n",
       "      <td>28.530</td>\n",
       "      <td>158767.95</td>\n",
       "      <td>149753.04</td>\n",
       "      <td>149835.16</td>\n",
       "      <td>2.94</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-11</th>\n",
       "      <td>16.59</td>\n",
       "      <td>17.24</td>\n",
       "      <td>1</td>\n",
       "      <td>15.90</td>\n",
       "      <td>58036.37</td>\n",
       "      <td>-1.77</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>18.298</td>\n",
       "      <td>20.068</td>\n",
       "      <td>21.648</td>\n",
       "      <td>46971.51</td>\n",
       "      <td>52066.53</td>\n",
       "      <td>58356.88</td>\n",
       "      <td>1.99</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-14</th>\n",
       "      <td>16.62</td>\n",
       "      <td>16.64</td>\n",
       "      <td>1</td>\n",
       "      <td>14.46</td>\n",
       "      <td>139701.77</td>\n",
       "      <td>-1.61</td>\n",
       "      <td>-10.02</td>\n",
       "      <td>14.726</td>\n",
       "      <td>14.363</td>\n",
       "      <td>16.881</td>\n",
       "      <td>98449.69</td>\n",
       "      <td>89159.54</td>\n",
       "      <td>101431.96</td>\n",
       "      <td>4.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-01</th>\n",
       "      <td>14.78</td>\n",
       "      <td>14.78</td>\n",
       "      <td>1</td>\n",
       "      <td>13.46</td>\n",
       "      <td>78985.85</td>\n",
       "      <td>-1.50</td>\n",
       "      <td>-10.03</td>\n",
       "      <td>15.080</td>\n",
       "      <td>17.434</td>\n",
       "      <td>18.617</td>\n",
       "      <td>109001.30</td>\n",
       "      <td>103741.22</td>\n",
       "      <td>106218.95</td>\n",
       "      <td>2.70</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-08-28  15.40  16.46      1  15.00  117827.60          1.50     10.03   \n",
       "2015-05-21  27.50  28.22      1  26.50  121190.11          2.57     10.02   \n",
       "2016-12-22  18.50  20.42      1  18.45  150470.83          1.86     10.02   \n",
       "2015-08-04  16.20  17.35      1  15.80   94292.63          1.58     10.02   \n",
       "2016-07-07  18.66  18.66      1  18.41   48756.55          1.70     10.02   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-08-26  17.00  18.35      1  15.56  130318.31         -1.73    -10.01   \n",
       "2015-07-15  22.78  23.04      1  22.10   85966.42         -2.46    -10.02   \n",
       "2016-01-11  16.59  17.24      1  15.90   58036.37         -1.77    -10.02   \n",
       "2015-09-14  16.62  16.64      1  14.46  139701.77         -1.61    -10.02   \n",
       "2015-09-01  14.78  14.78      1  13.46   78985.85         -1.50    -10.03   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-08-28  16.698  18.849  18.853   92680.85  109609.73  107384.89      4.03  \n",
       "2015-05-21  24.508  22.725  22.053  117760.48  103865.87   98766.20      4.15  \n",
       "2016-12-22  18.874  18.775  20.455   59074.51   77760.81   74734.64      3.77  \n",
       "2015-08-04  17.736  19.765  21.454   87169.08  104549.78  123074.95      3.23  \n",
       "2016-07-07  16.206  15.768  15.639   25103.33   30923.60   38378.63      1.67  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-08-26  18.742  20.042  19.087  100097.45  114432.06  102945.90      4.46  \n",
       "2015-07-15  24.564  25.197  28.530  158767.95  149753.04  149835.16      2.94  \n",
       "2016-01-11  18.298  20.068  21.648   46971.51   52066.53   58356.88      1.99  \n",
       "2015-09-14  14.726  14.363  16.881   98449.69   89159.54  101431.96      4.78  \n",
       "2015-09-01  15.080  17.434  18.617  109001.30  103741.22  106218.95      2.70  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 按照涨跌幅大小进行排序 , 使用ascending指定按照大小排序\n",
    "data.sort_values(by='p_change', ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "radio-circus",
   "metadata": {},
   "outputs": [],
   "source": [
    "data.sort_values(by=['open','high'], ascending=True, inplace=True)   # inplace 为True代表修改原始数据没有返回值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "reported-philadelphia",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-02</th>\n",
       "      <td>12.30</td>\n",
       "      <td>14.11</td>\n",
       "      <td>1</td>\n",
       "      <td>12.30</td>\n",
       "      <td>70201.74</td>\n",
       "      <td>-1.10</td>\n",
       "      <td>-8.17</td>\n",
       "      <td>14.440</td>\n",
       "      <td>16.591</td>\n",
       "      <td>18.360</td>\n",
       "      <td>96977.99</td>\n",
       "      <td>98537.72</td>\n",
       "      <td>104567.25</td>\n",
       "      <td>2.40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-11</th>\n",
       "      <td>33.17</td>\n",
       "      <td>34.98</td>\n",
       "      <td>1</td>\n",
       "      <td>32.51</td>\n",
       "      <td>173075.73</td>\n",
       "      <td>0.54</td>\n",
       "      <td>1.59</td>\n",
       "      <td>32.016</td>\n",
       "      <td>29.572</td>\n",
       "      <td>28.036</td>\n",
       "      <td>193141.45</td>\n",
       "      <td>151337.71</td>\n",
       "      <td>151428.57</td>\n",
       "      <td>5.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-01</th>\n",
       "      <td>33.85</td>\n",
       "      <td>34.34</td>\n",
       "      <td>1</td>\n",
       "      <td>33.10</td>\n",
       "      <td>232325.30</td>\n",
       "      <td>-0.61</td>\n",
       "      <td>-1.77</td>\n",
       "      <td>33.170</td>\n",
       "      <td>30.891</td>\n",
       "      <td>28.684</td>\n",
       "      <td>353499.64</td>\n",
       "      <td>346829.10</td>\n",
       "      <td>233701.92</td>\n",
       "      <td>5.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-10</th>\n",
       "      <td>34.10</td>\n",
       "      <td>36.35</td>\n",
       "      <td>1</td>\n",
       "      <td>32.23</td>\n",
       "      <td>269033.12</td>\n",
       "      <td>0.51</td>\n",
       "      <td>1.53</td>\n",
       "      <td>30.538</td>\n",
       "      <td>28.660</td>\n",
       "      <td>27.424</td>\n",
       "      <td>176305.53</td>\n",
       "      <td>152266.76</td>\n",
       "      <td>149078.50</td>\n",
       "      <td>9.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-12</th>\n",
       "      <td>34.69</td>\n",
       "      <td>35.98</td>\n",
       "      <td>1</td>\n",
       "      <td>34.01</td>\n",
       "      <td>159825.88</td>\n",
       "      <td>0.82</td>\n",
       "      <td>2.38</td>\n",
       "      <td>33.420</td>\n",
       "      <td>30.513</td>\n",
       "      <td>28.683</td>\n",
       "      <td>197248.25</td>\n",
       "      <td>154480.41</td>\n",
       "      <td>153888.00</td>\n",
       "      <td>5.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-15</th>\n",
       "      <td>34.99</td>\n",
       "      <td>34.99</td>\n",
       "      <td>1</td>\n",
       "      <td>31.69</td>\n",
       "      <td>199369.53</td>\n",
       "      <td>-3.52</td>\n",
       "      <td>-10.00</td>\n",
       "      <td>33.696</td>\n",
       "      <td>30.964</td>\n",
       "      <td>29.114</td>\n",
       "      <td>201148.55</td>\n",
       "      <td>164608.26</td>\n",
       "      <td>158362.17</td>\n",
       "      <td>6.82</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-09-02  12.30  14.11      1  12.30   70201.74         -1.10     -8.17   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-06-11  33.17  34.98      1  32.51  173075.73          0.54      1.59   \n",
       "2017-11-01  33.85  34.34      1  33.10  232325.30         -0.61     -1.77   \n",
       "2015-06-10  34.10  36.35      1  32.23  269033.12          0.51      1.53   \n",
       "2015-06-12  34.69  35.98      1  34.01  159825.88          0.82      2.38   \n",
       "2015-06-15  34.99  34.99      1  31.69  199369.53         -3.52    -10.00   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-09-02  14.440  16.591  18.360   96977.99   98537.72  104567.25      2.40  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-06-11  32.016  29.572  28.036  193141.45  151337.71  151428.57      5.92  \n",
       "2017-11-01  33.170  30.891  28.684  353499.64  346829.10  233701.92      5.81  \n",
       "2015-06-10  30.538  28.660  27.424  176305.53  152266.76  149078.50      9.21  \n",
       "2015-06-12  33.420  30.513  28.683  197248.25  154480.41  153888.00      5.47  \n",
       "2015-06-15  33.696  30.964  29.114  201148.55  164608.26  158362.17      6.82  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "obvious-elder",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>10</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-03  12.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  12.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  13.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-22  22.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "2018-02-23  22.88  23.37      1  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  22.80  23.78     10  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "strong-sewing",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>close</th>\n",
       "      <th>high</th>\n",
       "      <th>low</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>ma5</th>\n",
       "      <th>open</th>\n",
       "      <th>p_change</th>\n",
       "      <th>price_change</th>\n",
       "      <th>turnover</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>volume</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>1</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.20</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.25</td>\n",
       "      <td>2.62</td>\n",
       "      <td>0.32</td>\n",
       "      <td>3.30</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-09-02</th>\n",
       "      <td>1</td>\n",
       "      <td>14.11</td>\n",
       "      <td>12.30</td>\n",
       "      <td>16.591</td>\n",
       "      <td>18.360</td>\n",
       "      <td>14.440</td>\n",
       "      <td>12.30</td>\n",
       "      <td>-8.17</td>\n",
       "      <td>-1.10</td>\n",
       "      <td>2.40</td>\n",
       "      <td>98537.72</td>\n",
       "      <td>104567.25</td>\n",
       "      <td>96977.99</td>\n",
       "      <td>70201.74</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>1</td>\n",
       "      <td>13.06</td>\n",
       "      <td>12.52</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.52</td>\n",
       "      <td>1.44</td>\n",
       "      <td>0.18</td>\n",
       "      <td>4.76</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>139071.61</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>1</td>\n",
       "      <td>12.92</td>\n",
       "      <td>12.61</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.80</td>\n",
       "      <td>1.57</td>\n",
       "      <td>0.20</td>\n",
       "      <td>2.30</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>67075.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>1</td>\n",
       "      <td>13.45</td>\n",
       "      <td>12.87</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.88</td>\n",
       "      <td>2.02</td>\n",
       "      <td>0.26</td>\n",
       "      <td>3.19</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>93180.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-11</th>\n",
       "      <td>1</td>\n",
       "      <td>34.98</td>\n",
       "      <td>32.51</td>\n",
       "      <td>29.572</td>\n",
       "      <td>28.036</td>\n",
       "      <td>32.016</td>\n",
       "      <td>33.17</td>\n",
       "      <td>1.59</td>\n",
       "      <td>0.54</td>\n",
       "      <td>5.92</td>\n",
       "      <td>151337.71</td>\n",
       "      <td>151428.57</td>\n",
       "      <td>193141.45</td>\n",
       "      <td>173075.73</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-01</th>\n",
       "      <td>1</td>\n",
       "      <td>34.34</td>\n",
       "      <td>33.10</td>\n",
       "      <td>30.891</td>\n",
       "      <td>28.684</td>\n",
       "      <td>33.170</td>\n",
       "      <td>33.85</td>\n",
       "      <td>-1.77</td>\n",
       "      <td>-0.61</td>\n",
       "      <td>5.81</td>\n",
       "      <td>346829.10</td>\n",
       "      <td>233701.92</td>\n",
       "      <td>353499.64</td>\n",
       "      <td>232325.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-10</th>\n",
       "      <td>1</td>\n",
       "      <td>36.35</td>\n",
       "      <td>32.23</td>\n",
       "      <td>28.660</td>\n",
       "      <td>27.424</td>\n",
       "      <td>30.538</td>\n",
       "      <td>34.10</td>\n",
       "      <td>1.53</td>\n",
       "      <td>0.51</td>\n",
       "      <td>9.21</td>\n",
       "      <td>152266.76</td>\n",
       "      <td>149078.50</td>\n",
       "      <td>176305.53</td>\n",
       "      <td>269033.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-12</th>\n",
       "      <td>1</td>\n",
       "      <td>35.98</td>\n",
       "      <td>34.01</td>\n",
       "      <td>30.513</td>\n",
       "      <td>28.683</td>\n",
       "      <td>33.420</td>\n",
       "      <td>34.69</td>\n",
       "      <td>2.38</td>\n",
       "      <td>0.82</td>\n",
       "      <td>5.47</td>\n",
       "      <td>154480.41</td>\n",
       "      <td>153888.00</td>\n",
       "      <td>197248.25</td>\n",
       "      <td>159825.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-06-15</th>\n",
       "      <td>1</td>\n",
       "      <td>34.99</td>\n",
       "      <td>31.69</td>\n",
       "      <td>30.964</td>\n",
       "      <td>29.114</td>\n",
       "      <td>33.696</td>\n",
       "      <td>34.99</td>\n",
       "      <td>-10.00</td>\n",
       "      <td>-3.52</td>\n",
       "      <td>6.82</td>\n",
       "      <td>164608.26</td>\n",
       "      <td>158362.17</td>\n",
       "      <td>201148.55</td>\n",
       "      <td>199369.53</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            close   high    low    ma10    ma20     ma5   open  p_change  \\\n",
       "2015-03-02      1  12.67  12.20  12.520  12.520  12.520  12.25      2.62   \n",
       "2015-09-02      1  14.11  12.30  16.591  18.360  14.440  12.30     -8.17   \n",
       "2015-03-03      1  13.06  12.52  12.610  12.610  12.610  12.52      1.44   \n",
       "2015-03-04      1  12.92  12.61  12.707  12.707  12.707  12.80      1.57   \n",
       "2015-03-05      1  13.45  12.87  12.820  12.820  12.820  12.88      2.02   \n",
       "...           ...    ...    ...     ...     ...     ...    ...       ...   \n",
       "2015-06-11      1  34.98  32.51  29.572  28.036  32.016  33.17      1.59   \n",
       "2017-11-01      1  34.34  33.10  30.891  28.684  33.170  33.85     -1.77   \n",
       "2015-06-10      1  36.35  32.23  28.660  27.424  30.538  34.10      1.53   \n",
       "2015-06-12      1  35.98  34.01  30.513  28.683  33.420  34.69      2.38   \n",
       "2015-06-15      1  34.99  31.69  30.964  29.114  33.696  34.99    -10.00   \n",
       "\n",
       "            price_change  turnover     v_ma10     v_ma20      v_ma5     volume  \n",
       "2015-03-02          0.32      3.30   96291.73   96291.73   96291.73   96291.73  \n",
       "2015-09-02         -1.10      2.40   98537.72  104567.25   96977.99   70201.74  \n",
       "2015-03-03          0.18      4.76  117681.67  117681.67  117681.67  139071.61  \n",
       "2015-03-04          0.20      2.30  100812.93  100812.93  100812.93   67075.44  \n",
       "2015-03-05          0.26      3.19   98904.79   98904.79   98904.79   93180.39  \n",
       "...                  ...       ...        ...        ...        ...        ...  \n",
       "2015-06-11          0.54      5.92  151337.71  151428.57  193141.45  173075.73  \n",
       "2017-11-01         -0.61      5.81  346829.10  233701.92  353499.64  232325.30  \n",
       "2015-06-10          0.51      9.21  152266.76  149078.50  176305.53  269033.12  \n",
       "2015-06-12          0.82      5.47  154480.41  153888.00  197248.25  159825.88  \n",
       "2015-06-15         -3.52      6.82  164608.26  158362.17  201148.55  199369.53  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.sort_index(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "immediate-estate",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "      <td>643.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>21.272706</td>\n",
       "      <td>21.900513</td>\n",
       "      <td>1.013997</td>\n",
       "      <td>20.771835</td>\n",
       "      <td>99905.519114</td>\n",
       "      <td>0.018802</td>\n",
       "      <td>0.190280</td>\n",
       "      <td>21.302362</td>\n",
       "      <td>21.267656</td>\n",
       "      <td>21.200946</td>\n",
       "      <td>100008.642691</td>\n",
       "      <td>100287.542177</td>\n",
       "      <td>100797.518398</td>\n",
       "      <td>2.936190</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>3.930973</td>\n",
       "      <td>4.077578</td>\n",
       "      <td>0.354925</td>\n",
       "      <td>3.791968</td>\n",
       "      <td>73879.119354</td>\n",
       "      <td>0.898476</td>\n",
       "      <td>4.079698</td>\n",
       "      <td>3.880640</td>\n",
       "      <td>3.813602</td>\n",
       "      <td>3.686186</td>\n",
       "      <td>62761.578326</td>\n",
       "      <td>56759.082060</td>\n",
       "      <td>50101.575639</td>\n",
       "      <td>2.079375</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>12.250000</td>\n",
       "      <td>12.670000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>12.200000</td>\n",
       "      <td>1158.120000</td>\n",
       "      <td>-3.520000</td>\n",
       "      <td>-10.030000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>12.520000</td>\n",
       "      <td>10804.740000</td>\n",
       "      <td>19130.510000</td>\n",
       "      <td>23311.000000</td>\n",
       "      <td>0.040000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>19.000000</td>\n",
       "      <td>19.500000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>18.525000</td>\n",
       "      <td>48533.210000</td>\n",
       "      <td>-0.390000</td>\n",
       "      <td>-1.850000</td>\n",
       "      <td>18.990000</td>\n",
       "      <td>19.102000</td>\n",
       "      <td>19.275000</td>\n",
       "      <td>55794.985000</td>\n",
       "      <td>59861.955000</td>\n",
       "      <td>64103.675000</td>\n",
       "      <td>1.360000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>21.440000</td>\n",
       "      <td>21.970000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>20.980000</td>\n",
       "      <td>83175.930000</td>\n",
       "      <td>0.050000</td>\n",
       "      <td>0.260000</td>\n",
       "      <td>21.504000</td>\n",
       "      <td>21.623000</td>\n",
       "      <td>21.530000</td>\n",
       "      <td>86133.330000</td>\n",
       "      <td>89234.970000</td>\n",
       "      <td>96291.730000</td>\n",
       "      <td>2.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>23.400000</td>\n",
       "      <td>24.065000</td>\n",
       "      <td>1.000000</td>\n",
       "      <td>22.850000</td>\n",
       "      <td>127580.055000</td>\n",
       "      <td>0.455000</td>\n",
       "      <td>2.305000</td>\n",
       "      <td>23.318000</td>\n",
       "      <td>23.098500</td>\n",
       "      <td>23.136000</td>\n",
       "      <td>127655.655000</td>\n",
       "      <td>124693.255000</td>\n",
       "      <td>124001.015000</td>\n",
       "      <td>3.915000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>34.990000</td>\n",
       "      <td>36.350000</td>\n",
       "      <td>10.000000</td>\n",
       "      <td>34.010000</td>\n",
       "      <td>501915.410000</td>\n",
       "      <td>3.030000</td>\n",
       "      <td>10.030000</td>\n",
       "      <td>33.696000</td>\n",
       "      <td>32.186000</td>\n",
       "      <td>29.998000</td>\n",
       "      <td>404443.540000</td>\n",
       "      <td>360028.160000</td>\n",
       "      <td>269280.790000</td>\n",
       "      <td>12.560000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open        high       close         low         volume  \\\n",
       "count  643.000000  643.000000  643.000000  643.000000     643.000000   \n",
       "mean    21.272706   21.900513    1.013997   20.771835   99905.519114   \n",
       "std      3.930973    4.077578    0.354925    3.791968   73879.119354   \n",
       "min     12.250000   12.670000    1.000000   12.200000    1158.120000   \n",
       "25%     19.000000   19.500000    1.000000   18.525000   48533.210000   \n",
       "50%     21.440000   21.970000    1.000000   20.980000   83175.930000   \n",
       "75%     23.400000   24.065000    1.000000   22.850000  127580.055000   \n",
       "max     34.990000   36.350000   10.000000   34.010000  501915.410000   \n",
       "\n",
       "       price_change    p_change         ma5        ma10        ma20  \\\n",
       "count    643.000000  643.000000  643.000000  643.000000  643.000000   \n",
       "mean       0.018802    0.190280   21.302362   21.267656   21.200946   \n",
       "std        0.898476    4.079698    3.880640    3.813602    3.686186   \n",
       "min       -3.520000  -10.030000   12.520000   12.520000   12.520000   \n",
       "25%       -0.390000   -1.850000   18.990000   19.102000   19.275000   \n",
       "50%        0.050000    0.260000   21.504000   21.623000   21.530000   \n",
       "75%        0.455000    2.305000   23.318000   23.098500   23.136000   \n",
       "max        3.030000   10.030000   33.696000   32.186000   29.998000   \n",
       "\n",
       "               v_ma5         v_ma10         v_ma20    turnover  \n",
       "count     643.000000     643.000000     643.000000  643.000000  \n",
       "mean   100008.642691  100287.542177  100797.518398    2.936190  \n",
       "std     62761.578326   56759.082060   50101.575639    2.079375  \n",
       "min     10804.740000   19130.510000   23311.000000    0.040000  \n",
       "25%     55794.985000   59861.955000   64103.675000    1.360000  \n",
       "50%     86133.330000   89234.970000   96291.730000    2.500000  \n",
       "75%    127655.655000  124693.255000  124001.015000    3.915000  \n",
       "max    404443.540000  360028.160000  269280.790000   12.560000  "
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.describe()   # 综合统计数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "applicable-virginia",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open                34.990\n",
       "high                36.350\n",
       "close               10.000\n",
       "low                 34.010\n",
       "volume          501915.410\n",
       "price_change         3.030\n",
       "p_change            10.030\n",
       "ma5                 33.696\n",
       "ma10                32.186\n",
       "ma20                29.998\n",
       "v_ma5           404443.540\n",
       "v_ma10          360028.160\n",
       "v_ma20          269280.790\n",
       "turnover            12.560\n",
       "dtype: float64"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "solved-routine",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 单独计算\n",
    "data['close'].max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "pleasant-retirement",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-06-15\n",
       "high            2015-06-10\n",
       "close           2018-02-26\n",
       "low             2015-06-12\n",
       "volume          2017-10-26\n",
       "price_change    2015-06-09\n",
       "p_change        2015-08-28\n",
       "ma5             2015-06-15\n",
       "ma10            2015-06-18\n",
       "ma20            2015-06-18\n",
       "v_ma5           2017-10-26\n",
       "v_ma10          2017-11-02\n",
       "v_ma20          2017-11-15\n",
       "turnover        2017-10-26\n",
       "dtype: object"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 求出最大值的位置\n",
    "data.idxmax()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "marked-satellite",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "open            2015-03-02\n",
       "high            2015-03-02\n",
       "close           2015-03-02\n",
       "low             2015-03-02\n",
       "volume          2016-07-06\n",
       "price_change    2015-06-15\n",
       "p_change        2015-09-01\n",
       "ma5             2015-03-02\n",
       "ma10            2015-03-02\n",
       "ma20            2015-03-02\n",
       "v_ma5           2017-02-03\n",
       "v_ma10          2017-02-03\n",
       "v_ma20          2017-05-23\n",
       "turnover        2016-07-06\n",
       "dtype: object"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.idxmin()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "anonymous-asset",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 排序之后，进行累计求和\n",
    "data = data.sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "assigned-season",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    2.62\n",
       "2015-03-03    1.44\n",
       "2015-03-04    1.57\n",
       "2015-03-05    2.02\n",
       "2015-03-06    8.51\n",
       "              ... \n",
       "2018-02-14    2.05\n",
       "2018-02-22    1.64\n",
       "2018-02-23    2.42\n",
       "2018-02-26    3.02\n",
       "2018-02-27    2.68\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#计算累计函数\n",
    "stock_rise = data['p_change']   # 每一天的涨幅\n",
    "stock_rise"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "decreased-maria",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02      2.62\n",
       "2015-03-03      4.06\n",
       "2015-03-04      5.63\n",
       "2015-03-05      7.65\n",
       "2015-03-06     16.16\n",
       "               ...  \n",
       "2018-02-14    112.59\n",
       "2018-02-22    114.23\n",
       "2018-02-23    116.65\n",
       "2018-02-26    119.67\n",
       "2018-02-27    122.35\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# plot方法集成了前面直方图、条形图、饼图、折线图\n",
    "stock_rise.cumsum()   # 累积求和"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "personal-bidder",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD7CAYAAACRxdTpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8vihELAAAACXBIWXMAAAsTAAALEwEAmpwYAABJAElEQVR4nO2dd3gc5bX/P+82raolWZK7cTeYamxa6J1AKAlJrgkhhCTX9yakV0jCjzRuSCMJISQhCS0BTAm5cFMA06sxbhiMe5erbFl9V9ve3x8zszu72tWutkir1fk8jx/tTtuz49nvnDnvec9RWmsEQRCE0sIx1AYIgiAI+UfEXRAEoQQRcRcEQShBRNwFQRBKEBF3QRCEEkTEXRAEoQRJK+5KqbuVUvuVUu8mLP+CUmq9UmqNUuqntuU3KqU2mesuLITRgiAIQv+4MtjmXuAO4H5rgVLqbOBy4Bitda9SqslcPgdYABwJjAeeVUrN0lqH8224IAiCkJq04q61flkpNSVh8WeBW7XWveY2+83llwOLzOVblVKbgBOBN/r7jIaGBj1lSuJHCIIgCP2xfPnyA1rrxmTrMvHckzELOF0pdQvgB76utX4LmAAssW3XbC7rlylTprBs2bIsTREEQRiZKKW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PtfT2xAdQFG9sCvMH6Yz2F4AoNuv7lutmmP6uecz7Sd++eBfQnrFxE/oJo32237JA4szcXI2pmZZr/odvbrBsPrGm2e918B7wLfTme77fueY1v/6ACvmwbAYb6+BfhBmu9wL/Bhkl/3/yJ+QDWt/ebyW4Hvp/ncvFz35v4vAxvM5dZ1/zwDuObzYfsArnn7ddNHczDCSIsKZX8+r/sU68+iCLNlTsN4xFpNLKXoYowf6nMYKWHPAfW2fbZheJddGHf1ORiPVcvN46wBfg04U3zmfIwf/2aMASArrerX5r6rMAbGjkyxvxfDw9uEkd1g2b/dfL0ZI62q01w2KPab674H3JrmnFvfc6Nprz2F8V0MjzeMEbtemWfbf2ruFzH/fs9c/izG4K5lx5Mp9re2s2xvN7d/GyOFcL25LKPzbi4/DEOsrDSzyQO8bj5s2rMBYzC3LMX+1kB1t2ljsuv+eoy4dkbXvW3dFuDwNP/v+brum03b15n7bMcIQ1nXfC/m2E2hbR/ANW+/vqxrxzr372Fc8w0MQHMGaH++rvs+22EM4rYAPvPYF2ajxTJDVRAEoQSRGaqCIAgliIi7IAhCCSLiLgiCUIKIuAuCIJQgIu6CIAgliIi7IAhCCSLiLgiCUIKIuAuCIJQg/x/ntr3YsIVV+wAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "stock_rise.cumsum().plot()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "trained-account",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02     2.62\n",
       "2015-03-03     2.62\n",
       "2015-03-04     2.62\n",
       "2015-03-05     2.62\n",
       "2015-03-06     8.51\n",
       "              ...  \n",
       "2018-02-14    10.03\n",
       "2018-02-22    10.03\n",
       "2018-02-23    10.03\n",
       "2018-02-26    10.03\n",
       "2018-02-27    10.03\n",
       "Name: p_change, Length: 643, dtype: float64"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_rise.cummax()  # 累积求最大值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "nominated-taste",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02     True\n",
       "2015-03-03    False\n",
       "2015-03-04    False\n",
       "2015-03-05     True\n",
       "2015-03-06     True\n",
       "              ...  \n",
       "2018-02-14     True\n",
       "2018-02-22    False\n",
       "2018-02-23     True\n",
       "2018-02-26     True\n",
       "2018-02-27     True\n",
       "Name: p_change, Length: 643, dtype: bool"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['p_change'] > 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "right-sleeve",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-10</th>\n",
       "      <td>14.20</td>\n",
       "      <td>14.80</td>\n",
       "      <td>1</td>\n",
       "      <td>14.01</td>\n",
       "      <td>101213.51</td>\n",
       "      <td>0.34</td>\n",
       "      <td>2.38</td>\n",
       "      <td>13.860</td>\n",
       "      <td>13.503</td>\n",
       "      <td>13.503</td>\n",
       "      <td>117249.34</td>\n",
       "      <td>117372.87</td>\n",
       "      <td>117372.87</td>\n",
       "      <td>3.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-13</th>\n",
       "      <td>14.13</td>\n",
       "      <td>14.50</td>\n",
       "      <td>1</td>\n",
       "      <td>14.08</td>\n",
       "      <td>61342.22</td>\n",
       "      <td>0.36</td>\n",
       "      <td>2.55</td>\n",
       "      <td>14.368</td>\n",
       "      <td>13.740</td>\n",
       "      <td>13.740</td>\n",
       "      <td>102437.64</td>\n",
       "      <td>108763.91</td>\n",
       "      <td>108763.91</td>\n",
       "      <td>2.10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-12</th>\n",
       "      <td>20.70</td>\n",
       "      <td>21.40</td>\n",
       "      <td>1</td>\n",
       "      <td>20.63</td>\n",
       "      <td>32445.39</td>\n",
       "      <td>0.82</td>\n",
       "      <td>4.03</td>\n",
       "      <td>21.504</td>\n",
       "      <td>22.338</td>\n",
       "      <td>23.533</td>\n",
       "      <td>44645.16</td>\n",
       "      <td>45679.94</td>\n",
       "      <td>68686.33</td>\n",
       "      <td>0.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>10</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>183 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  12.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-05  12.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  13.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "2015-03-10  14.20  14.80      1  14.01  101213.51          0.34      2.38   \n",
       "2015-03-13  14.13  14.50      1  14.08   61342.22          0.36      2.55   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-12  20.70  21.40      1  20.63   32445.39          0.82      4.03   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-23  22.88  23.37      1  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  22.80  23.78     10  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "2015-03-10  13.860  13.503  13.503  117249.34  117372.87  117372.87      3.46  \n",
       "2015-03-13  14.368  13.740  13.740  102437.64  108763.91  108763.91      2.10  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-12  21.504  22.338  23.533   44645.16   45679.94   68686.33      0.81  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "\n",
       "[183 rows x 14 columns]"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 进行逻辑判断\n",
    "# 用true false进行标记，逻辑判断的结果可以作为筛选的依据\n",
    "data[ data['p_change'] > 2 ]     # 数据过滤"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "million-score",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-04-14</th>\n",
       "      <td>21.45</td>\n",
       "      <td>23.24</td>\n",
       "      <td>1</td>\n",
       "      <td>21.45</td>\n",
       "      <td>154693.44</td>\n",
       "      <td>2.11</td>\n",
       "      <td>9.99</td>\n",
       "      <td>20.368</td>\n",
       "      <td>18.494</td>\n",
       "      <td>16.982</td>\n",
       "      <td>156064.66</td>\n",
       "      <td>121417.14</td>\n",
       "      <td>114763.57</td>\n",
       "      <td>5.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-15</th>\n",
       "      <td>23.45</td>\n",
       "      <td>25.56</td>\n",
       "      <td>1</td>\n",
       "      <td>23.40</td>\n",
       "      <td>250311.59</td>\n",
       "      <td>1.14</td>\n",
       "      <td>4.91</td>\n",
       "      <td>21.560</td>\n",
       "      <td>19.315</td>\n",
       "      <td>17.442</td>\n",
       "      <td>174581.78</td>\n",
       "      <td>138001.54</td>\n",
       "      <td>119340.61</td>\n",
       "      <td>8.57</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-21</th>\n",
       "      <td>21.00</td>\n",
       "      <td>21.97</td>\n",
       "      <td>1</td>\n",
       "      <td>20.80</td>\n",
       "      <td>111028.80</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.07</td>\n",
       "      <td>22.478</td>\n",
       "      <td>21.423</td>\n",
       "      <td>18.772</td>\n",
       "      <td>193934.80</td>\n",
       "      <td>174999.73</td>\n",
       "      <td>136236.51</td>\n",
       "      <td>3.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-04-27</th>\n",
       "      <td>22.56</td>\n",
       "      <td>23.65</td>\n",
       "      <td>1</td>\n",
       "      <td>22.56</td>\n",
       "      <td>159325.12</td>\n",
       "      <td>1.42</td>\n",
       "      <td>6.61</td>\n",
       "      <td>21.952</td>\n",
       "      <td>22.368</td>\n",
       "      <td>20.090</td>\n",
       "      <td>121509.68</td>\n",
       "      <td>162088.70</td>\n",
       "      <td>138272.77</td>\n",
       "      <td>5.45</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-05-11</th>\n",
       "      <td>20.31</td>\n",
       "      <td>20.84</td>\n",
       "      <td>1</td>\n",
       "      <td>20.15</td>\n",
       "      <td>78920.74</td>\n",
       "      <td>0.58</td>\n",
       "      <td>2.90</td>\n",
       "      <td>19.916</td>\n",
       "      <td>21.108</td>\n",
       "      <td>21.649</td>\n",
       "      <td>82304.64</td>\n",
       "      <td>90837.92</td>\n",
       "      <td>127088.19</td>\n",
       "      <td>2.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-12</th>\n",
       "      <td>20.70</td>\n",
       "      <td>21.40</td>\n",
       "      <td>1</td>\n",
       "      <td>20.63</td>\n",
       "      <td>32445.39</td>\n",
       "      <td>0.82</td>\n",
       "      <td>4.03</td>\n",
       "      <td>21.504</td>\n",
       "      <td>22.338</td>\n",
       "      <td>23.533</td>\n",
       "      <td>44645.16</td>\n",
       "      <td>45679.94</td>\n",
       "      <td>68686.33</td>\n",
       "      <td>0.81</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>10</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>113 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-04-14  21.45  23.24      1  21.45  154693.44          2.11      9.99   \n",
       "2015-04-15  23.45  25.56      1  23.40  250311.59          1.14      4.91   \n",
       "2015-04-21  21.00  21.97      1  20.80  111028.80          0.44      2.07   \n",
       "2015-04-27  22.56  23.65      1  22.56  159325.12          1.42      6.61   \n",
       "2015-05-11  20.31  20.84      1  20.15   78920.74          0.58      2.90   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-12  20.70  21.40      1  20.63   32445.39          0.82      4.03   \n",
       "2018-02-14  21.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-23  22.88  23.37      1  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  22.80  23.78     10  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  23.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-04-14  20.368  18.494  16.982  156064.66  121417.14  114763.57      5.30  \n",
       "2015-04-15  21.560  19.315  17.442  174581.78  138001.54  119340.61      8.57  \n",
       "2015-04-21  22.478  21.423  18.772  193934.80  174999.73  136236.51      3.80  \n",
       "2015-04-27  21.952  22.368  20.090  121509.68  162088.70  138272.77      5.45  \n",
       "2015-05-11  19.916  21.108  21.649   82304.64   90837.92  127088.19      2.70  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-12  21.504  22.338  23.533   44645.16   45679.94   68686.33      0.81  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "\n",
       "[113 rows x 14 columns]"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 完成一个符合逻辑判断， p_change > 2, open > 15\n",
    "data[(data['p_change'] > 2) & (data['open'] > 20)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "driven-response",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2015-03-02    False\n",
       "2015-03-03    False\n",
       "2015-03-04    False\n",
       "2015-03-05    False\n",
       "2015-03-06    False\n",
       "              ...  \n",
       "2018-02-14    False\n",
       "2018-02-22    False\n",
       "2018-02-23    False\n",
       "2018-02-26    False\n",
       "2018-02-27    False\n",
       "Name: turnover, Length: 643, dtype: bool"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data['turnover'].isin([4.19])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "fabulous-remedy",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-04-07</th>\n",
       "      <td>16.54</td>\n",
       "      <td>17.98</td>\n",
       "      <td>1</td>\n",
       "      <td>16.50</td>\n",
       "      <td>122471.85</td>\n",
       "      <td>0.88</td>\n",
       "      <td>5.28</td>\n",
       "      <td>16.620</td>\n",
       "      <td>16.120</td>\n",
       "      <td>15.510</td>\n",
       "      <td>86769.62</td>\n",
       "      <td>97473.29</td>\n",
       "      <td>98832.94</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-02-23</th>\n",
       "      <td>16.56</td>\n",
       "      <td>16.58</td>\n",
       "      <td>1</td>\n",
       "      <td>15.70</td>\n",
       "      <td>38420.64</td>\n",
       "      <td>-0.29</td>\n",
       "      <td>-1.76</td>\n",
       "      <td>16.166</td>\n",
       "      <td>15.642</td>\n",
       "      <td>15.200</td>\n",
       "      <td>41152.50</td>\n",
       "      <td>36408.46</td>\n",
       "      <td>36212.09</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-25</th>\n",
       "      <td>23.07</td>\n",
       "      <td>24.20</td>\n",
       "      <td>1</td>\n",
       "      <td>22.64</td>\n",
       "      <td>167489.48</td>\n",
       "      <td>0.67</td>\n",
       "      <td>2.91</td>\n",
       "      <td>23.042</td>\n",
       "      <td>22.759</td>\n",
       "      <td>22.199</td>\n",
       "      <td>137135.54</td>\n",
       "      <td>156145.65</td>\n",
       "      <td>166607.70</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-06</th>\n",
       "      <td>21.66</td>\n",
       "      <td>22.10</td>\n",
       "      <td>1</td>\n",
       "      <td>21.51</td>\n",
       "      <td>52664.77</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.66</td>\n",
       "      <td>23.022</td>\n",
       "      <td>23.679</td>\n",
       "      <td>25.459</td>\n",
       "      <td>62062.10</td>\n",
       "      <td>60285.78</td>\n",
       "      <td>98491.69</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-04-07  16.54  17.98      1  16.50  122471.85          0.88      5.28   \n",
       "2016-02-23  16.56  16.58      1  15.70   38420.64         -0.29     -1.76   \n",
       "2017-07-25  23.07  24.20      1  22.64  167489.48          0.67      2.91   \n",
       "2017-12-06  21.66  22.10      1  21.51   52664.77          0.36      1.66   \n",
       "2018-02-23  22.88  23.37      1  22.71   52914.01          0.54      2.42   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-04-07  16.620  16.120  15.510   86769.62   97473.29   98832.94      4.19  \n",
       "2016-02-23  16.166  15.642  15.200   41152.50   36408.46   36212.09      1.32  \n",
       "2017-07-25  23.042  22.759  22.199  137135.54  156145.65  166607.70      4.19  \n",
       "2017-12-06  23.022  23.679  25.459   62062.10   60285.78   98491.69      1.32  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  "
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 可以指定值进行一个判断，从而进行筛选操作\n",
    "data[      data['turnover'].isin([4.19, 1.32])    ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "unable-blogger",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>14.25</td>\n",
       "      <td>13.67</td>\n",
       "      <td>2</td>\n",
       "      <td>13.20</td>\n",
       "      <td>96292.73</td>\n",
       "      <td>1.32</td>\n",
       "      <td>3.62</td>\n",
       "      <td>13.520</td>\n",
       "      <td>13.520</td>\n",
       "      <td>13.520</td>\n",
       "      <td>96292.73</td>\n",
       "      <td>96292.73</td>\n",
       "      <td>96292.73</td>\n",
       "      <td>4.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>14.52</td>\n",
       "      <td>14.06</td>\n",
       "      <td>2</td>\n",
       "      <td>13.52</td>\n",
       "      <td>139072.61</td>\n",
       "      <td>1.18</td>\n",
       "      <td>2.44</td>\n",
       "      <td>13.610</td>\n",
       "      <td>13.610</td>\n",
       "      <td>13.610</td>\n",
       "      <td>117682.67</td>\n",
       "      <td>117682.67</td>\n",
       "      <td>117682.67</td>\n",
       "      <td>5.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>14.80</td>\n",
       "      <td>13.92</td>\n",
       "      <td>2</td>\n",
       "      <td>13.61</td>\n",
       "      <td>67076.44</td>\n",
       "      <td>1.20</td>\n",
       "      <td>2.57</td>\n",
       "      <td>13.707</td>\n",
       "      <td>13.707</td>\n",
       "      <td>13.707</td>\n",
       "      <td>100813.93</td>\n",
       "      <td>100813.93</td>\n",
       "      <td>100813.93</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>14.88</td>\n",
       "      <td>14.45</td>\n",
       "      <td>2</td>\n",
       "      <td>13.87</td>\n",
       "      <td>93181.39</td>\n",
       "      <td>1.26</td>\n",
       "      <td>3.02</td>\n",
       "      <td>13.820</td>\n",
       "      <td>13.820</td>\n",
       "      <td>13.820</td>\n",
       "      <td>98905.79</td>\n",
       "      <td>98905.79</td>\n",
       "      <td>98905.79</td>\n",
       "      <td>4.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>15.17</td>\n",
       "      <td>15.48</td>\n",
       "      <td>2</td>\n",
       "      <td>14.13</td>\n",
       "      <td>179832.72</td>\n",
       "      <td>2.12</td>\n",
       "      <td>9.51</td>\n",
       "      <td>14.112</td>\n",
       "      <td>14.112</td>\n",
       "      <td>14.112</td>\n",
       "      <td>115091.18</td>\n",
       "      <td>115091.18</td>\n",
       "      <td>115091.18</td>\n",
       "      <td>7.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>23.49</td>\n",
       "      <td>22.99</td>\n",
       "      <td>2</td>\n",
       "      <td>22.48</td>\n",
       "      <td>23332.04</td>\n",
       "      <td>1.44</td>\n",
       "      <td>3.05</td>\n",
       "      <td>22.366</td>\n",
       "      <td>22.923</td>\n",
       "      <td>24.253</td>\n",
       "      <td>33591.21</td>\n",
       "      <td>42936.74</td>\n",
       "      <td>61717.11</td>\n",
       "      <td>1.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>24.25</td>\n",
       "      <td>23.76</td>\n",
       "      <td>2</td>\n",
       "      <td>23.02</td>\n",
       "      <td>36106.01</td>\n",
       "      <td>1.36</td>\n",
       "      <td>2.64</td>\n",
       "      <td>22.446</td>\n",
       "      <td>22.909</td>\n",
       "      <td>24.137</td>\n",
       "      <td>35398.58</td>\n",
       "      <td>39905.78</td>\n",
       "      <td>60150.60</td>\n",
       "      <td>1.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>24.88</td>\n",
       "      <td>24.37</td>\n",
       "      <td>2</td>\n",
       "      <td>23.71</td>\n",
       "      <td>52915.01</td>\n",
       "      <td>1.54</td>\n",
       "      <td>3.42</td>\n",
       "      <td>22.938</td>\n",
       "      <td>22.929</td>\n",
       "      <td>24.022</td>\n",
       "      <td>35120.58</td>\n",
       "      <td>41872.97</td>\n",
       "      <td>56373.85</td>\n",
       "      <td>2.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>24.80</td>\n",
       "      <td>24.78</td>\n",
       "      <td>11</td>\n",
       "      <td>23.80</td>\n",
       "      <td>60986.11</td>\n",
       "      <td>1.69</td>\n",
       "      <td>4.02</td>\n",
       "      <td>23.406</td>\n",
       "      <td>22.955</td>\n",
       "      <td>23.942</td>\n",
       "      <td>40828.52</td>\n",
       "      <td>42737.34</td>\n",
       "      <td>56008.50</td>\n",
       "      <td>2.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>25.53</td>\n",
       "      <td>26.88</td>\n",
       "      <td>2</td>\n",
       "      <td>24.53</td>\n",
       "      <td>95579.03</td>\n",
       "      <td>1.63</td>\n",
       "      <td>3.68</td>\n",
       "      <td>23.942</td>\n",
       "      <td>23.142</td>\n",
       "      <td>23.875</td>\n",
       "      <td>53783.64</td>\n",
       "      <td>46739.65</td>\n",
       "      <td>55577.11</td>\n",
       "      <td>3.39</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  14.25  13.67      2  13.20   96292.73          1.32      3.62   \n",
       "2015-03-03  14.52  14.06      2  13.52  139072.61          1.18      2.44   \n",
       "2015-03-04  14.80  13.92      2  13.61   67076.44          1.20      2.57   \n",
       "2015-03-05  14.88  14.45      2  13.87   93181.39          1.26      3.02   \n",
       "2015-03-06  15.17  15.48      2  14.13  179832.72          2.12      9.51   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-14  23.49  22.99      2  22.48   23332.04          1.44      3.05   \n",
       "2018-02-22  24.25  23.76      2  23.02   36106.01          1.36      2.64   \n",
       "2018-02-23  24.88  24.37      2  23.71   52915.01          1.54      3.42   \n",
       "2018-02-26  24.80  24.78     11  23.80   60986.11          1.69      4.02   \n",
       "2018-02-27  25.53  26.88      2  24.53   95579.03          1.63      3.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2015-03-02  13.520  13.520  13.520   96292.73   96292.73   96292.73      4.30  \n",
       "2015-03-03  13.610  13.610  13.610  117682.67  117682.67  117682.67      5.76  \n",
       "2015-03-04  13.707  13.707  13.707  100813.93  100813.93  100813.93      3.30  \n",
       "2015-03-05  13.820  13.820  13.820   98905.79   98905.79   98905.79      4.19  \n",
       "2015-03-06  14.112  14.112  14.112  115091.18  115091.18  115091.18      7.16  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2018-02-14  22.366  22.923  24.253   33591.21   42936.74   61717.11      1.58  \n",
       "2018-02-22  22.446  22.909  24.137   35398.58   39905.78   60150.60      1.90  \n",
       "2018-02-23  22.938  22.929  24.022   35120.58   41872.97   56373.85      2.32  \n",
       "2018-02-26  23.406  22.955  23.942   40828.52   42737.34   56008.50      2.53  \n",
       "2018-02-27  23.942  23.142  23.875   53783.64   46739.65   55577.11      3.39  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 进行数学运算 加上具体的一个数字\n",
    "data.add(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "acoustic-stopping",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['open'] = data['open'] + 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "otherwise-netscape",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自己求出每天 close- open 价格差\n",
    "# 筛选两列数据\n",
    "close = data['close']\n",
    "open1 = data['open']\n",
    "# 默认按照索引对齐\n",
    "data['m_price_change'] = close.sub(open1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "photographic-statistics",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "      <th>m_price_change</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>13.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>1</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "      <td>-12.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>13.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>1</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "      <td>-12.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>13.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>1</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "      <td>-12.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>13.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>1</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "      <td>-12.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>14.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>1</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "      <td>-13.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>22.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>1</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "      <td>-21.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>23.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>1</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "      <td>-22.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>23.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>1</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "      <td>-22.88</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>23.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>10</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "      <td>-13.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>24.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>1</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "      <td>-23.53</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 15 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2015-03-02  13.25  12.67      1  12.20   96291.73          0.32      2.62   \n",
       "2015-03-03  13.52  13.06      1  12.52  139071.61          0.18      1.44   \n",
       "2015-03-04  13.80  12.92      1  12.61   67075.44          0.20      1.57   \n",
       "2015-03-05  13.88  13.45      1  12.87   93180.39          0.26      2.02   \n",
       "2015-03-06  14.17  14.48      1  13.13  179831.72          1.12      8.51   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2018-02-14  22.49  21.99      1  21.48   23331.04          0.44      2.05   \n",
       "2018-02-22  23.25  22.76      1  22.02   36105.01          0.36      1.64   \n",
       "2018-02-23  23.88  23.37      1  22.71   52914.01          0.54      2.42   \n",
       "2018-02-26  23.80  23.78     10  22.80   60985.11          0.69      3.02   \n",
       "2018-02-27  24.53  25.88      1  23.53   95578.03          0.63      2.68   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \\\n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30   \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76   \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30   \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19   \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16   \n",
       "...            ...     ...     ...        ...        ...        ...       ...   \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58   \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90   \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32   \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53   \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39   \n",
       "\n",
       "            m_price_change  \n",
       "2015-03-02          -12.25  \n",
       "2015-03-03          -12.52  \n",
       "2015-03-04          -12.80  \n",
       "2015-03-05          -12.88  \n",
       "2015-03-06          -13.17  \n",
       "...                    ...  \n",
       "2018-02-14          -21.49  \n",
       "2018-02-22          -22.25  \n",
       "2018-02-23          -22.88  \n",
       "2018-02-26          -13.80  \n",
       "2018-02-27          -23.53  \n",
       "\n",
       "[643 rows x 15 columns]"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "dying-grade",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   month  year  sale\n",
       "0      1     1    55\n",
       "1      4     1    40\n",
       "2      7     2    84\n",
       "3     10     2    31"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame({'month':[1,4,7,10], 'year':[1, 1, 2, 2], 'sale':[55, 40, 84, 31]})\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "dressed-taiwan",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['年龄'] = [10,20,30, 40]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 74,
   "id": "sweet-berry",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>month</th>\n",
       "      <th>year</th>\n",
       "      <th>sale</th>\n",
       "      <th>姓名</th>\n",
       "      <th>年龄</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>55</td>\n",
       "      <td>李四</td>\n",
       "      <td>10</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>40</td>\n",
       "      <td>李四</td>\n",
       "      <td>20</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>7</td>\n",
       "      <td>2</td>\n",
       "      <td>84</td>\n",
       "      <td>李四</td>\n",
       "      <td>30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>10</td>\n",
       "      <td>2</td>\n",
       "      <td>31</td>\n",
       "      <td>李四</td>\n",
       "      <td>40</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   month  year  sale  姓名  年龄\n",
       "0      1     1    55  李四  10\n",
       "1      4     1    40  李四  20\n",
       "2      7     2    84  李四  30\n",
       "3     10     2    31  李四  40"
      ]
     },
     "execution_count": 74,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "tracked-friendship",
   "metadata": {},
   "source": [
    "### 文件的读取与存储"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "swedish-partner",
   "metadata": {},
   "source": [
    "#### read_csv与to_csv"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "id": "civic-environment",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv('data/stock_day.csv',usecols=['open','high','close'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "id": "provincial-warehouse",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>14.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>13.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>12.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>12.70</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.52</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close\n",
       "2018-02-27  23.53  25.88  24.16\n",
       "2018-02-26  22.80  23.78  23.53\n",
       "2018-02-23  22.88  23.37  22.82\n",
       "2018-02-22  22.25  22.76  22.28\n",
       "2018-02-14  21.49  21.99  21.92\n",
       "...           ...    ...    ...\n",
       "2015-03-06  13.17  14.48  14.28\n",
       "2015-03-05  12.88  13.45  13.16\n",
       "2015-03-04  12.80  12.92  12.90\n",
       "2015-03-03  12.52  13.06  12.70\n",
       "2015-03-02  12.25  12.67  12.52\n",
       "\n",
       "[643 rows x 3 columns]"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "bored-utility",
   "metadata": {},
   "outputs": [],
   "source": [
    "data.head().to_csv('data/stock_day_head5.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "noble-shelf",
   "metadata": {},
   "outputs": [],
   "source": [
    "data5 = pd.read_csv('data/stock_day_head5.csv', index_col=0)    # 指定第0列为索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "deadly-aquatic",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close\n",
       "2018-02-27  23.53  25.88  24.16\n",
       "2018-02-26  22.80  23.78  23.53\n",
       "2018-02-23  22.88  23.37  22.82\n",
       "2018-02-22  22.25  22.76  22.28\n",
       "2018-02-14  21.49  21.99  21.92"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data5"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ignored-latvia",
   "metadata": {},
   "source": [
    "![](imgs/Snipaste_2021-10-15_16-22-47.png)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "lesser-spray",
   "metadata": {},
   "outputs": [],
   "source": [
    "data5.to_hdf('data/stock.h5', key='csmz')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "successful-tension",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close\n",
       "2018-02-27  23.53  25.88  24.16\n",
       "2018-02-26  22.80  23.78  23.53\n",
       "2018-02-23  22.88  23.37  22.82\n",
       "2018-02-22  22.25  22.76  22.28\n",
       "2018-02-14  21.49  21.99  21.92"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_hdf('data/stock.h5', key='csmz')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "painful-comparison",
   "metadata": {},
   "source": [
    "### 缺失值处理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "naval-coffee",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie = pd.read_csv('data/movie.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "fifth-frequency",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Guardians of the Galaxy</td>\n",
       "      <td>Action,Adventure,Sci-Fi</td>\n",
       "      <td>A group of intergalactic criminals are forced ...</td>\n",
       "      <td>James Gunn</td>\n",
       "      <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n",
       "      <td>2014</td>\n",
       "      <td>121</td>\n",
       "      <td>8.1</td>\n",
       "      <td>757074</td>\n",
       "      <td>333.13</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Prometheus</td>\n",
       "      <td>Adventure,Mystery,Sci-Fi</td>\n",
       "      <td>Following clues to the origin of mankind, a te...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n",
       "      <td>2012</td>\n",
       "      <td>124</td>\n",
       "      <td>7.0</td>\n",
       "      <td>485820</td>\n",
       "      <td>126.46</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Split</td>\n",
       "      <td>Horror,Thriller</td>\n",
       "      <td>Three girls are kidnapped by a man with a diag...</td>\n",
       "      <td>M. Night Shyamalan</td>\n",
       "      <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n",
       "      <td>2016</td>\n",
       "      <td>117</td>\n",
       "      <td>7.3</td>\n",
       "      <td>157606</td>\n",
       "      <td>138.12</td>\n",
       "      <td>62.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Sing</td>\n",
       "      <td>Animation,Comedy,Family</td>\n",
       "      <td>In a city of humanoid animals, a hustling thea...</td>\n",
       "      <td>Christophe Lourdelet</td>\n",
       "      <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n",
       "      <td>2016</td>\n",
       "      <td>108</td>\n",
       "      <td>7.2</td>\n",
       "      <td>60545</td>\n",
       "      <td>270.32</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Suicide Squad</td>\n",
       "      <td>Action,Adventure,Fantasy</td>\n",
       "      <td>A secret government agency recruits some of th...</td>\n",
       "      <td>David Ayer</td>\n",
       "      <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n",
       "      <td>2016</td>\n",
       "      <td>123</td>\n",
       "      <td>6.2</td>\n",
       "      <td>393727</td>\n",
       "      <td>325.02</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>996</td>\n",
       "      <td>Secret in Their Eyes</td>\n",
       "      <td>Crime,Drama,Mystery</td>\n",
       "      <td>A tight-knit team of rising investigators, alo...</td>\n",
       "      <td>Billy Ray</td>\n",
       "      <td>Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...</td>\n",
       "      <td>2015</td>\n",
       "      <td>111</td>\n",
       "      <td>6.2</td>\n",
       "      <td>27585</td>\n",
       "      <td>NaN</td>\n",
       "      <td>45.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>997</td>\n",
       "      <td>Hostel: Part II</td>\n",
       "      <td>Horror</td>\n",
       "      <td>Three American college students studying abroa...</td>\n",
       "      <td>Eli Roth</td>\n",
       "      <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n",
       "      <td>2007</td>\n",
       "      <td>94</td>\n",
       "      <td>5.5</td>\n",
       "      <td>73152</td>\n",
       "      <td>17.54</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>998</td>\n",
       "      <td>Step Up 2: The Streets</td>\n",
       "      <td>Drama,Music,Romance</td>\n",
       "      <td>Romantic sparks occur between two dance studen...</td>\n",
       "      <td>Jon M. Chu</td>\n",
       "      <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n",
       "      <td>2008</td>\n",
       "      <td>98</td>\n",
       "      <td>6.2</td>\n",
       "      <td>70699</td>\n",
       "      <td>58.01</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>999</td>\n",
       "      <td>Search Party</td>\n",
       "      <td>Adventure,Comedy</td>\n",
       "      <td>A pair of friends embark on a mission to reuni...</td>\n",
       "      <td>Scot Armstrong</td>\n",
       "      <td>Adam Pally, T.J. Miller, Thomas Middleditch,Sh...</td>\n",
       "      <td>2014</td>\n",
       "      <td>93</td>\n",
       "      <td>5.6</td>\n",
       "      <td>4881</td>\n",
       "      <td>NaN</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Nine Lives</td>\n",
       "      <td>Comedy,Family,Fantasy</td>\n",
       "      <td>A stuffy businessman finds himself trapped ins...</td>\n",
       "      <td>Barry Sonnenfeld</td>\n",
       "      <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n",
       "      <td>2016</td>\n",
       "      <td>87</td>\n",
       "      <td>5.3</td>\n",
       "      <td>12435</td>\n",
       "      <td>19.64</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank                    Title                     Genre  \\\n",
       "0       1  Guardians of the Galaxy   Action,Adventure,Sci-Fi   \n",
       "1       2               Prometheus  Adventure,Mystery,Sci-Fi   \n",
       "2       3                    Split           Horror,Thriller   \n",
       "3       4                     Sing   Animation,Comedy,Family   \n",
       "4       5            Suicide Squad  Action,Adventure,Fantasy   \n",
       "..    ...                      ...                       ...   \n",
       "995   996     Secret in Their Eyes       Crime,Drama,Mystery   \n",
       "996   997          Hostel: Part II                    Horror   \n",
       "997   998   Step Up 2: The Streets       Drama,Music,Romance   \n",
       "998   999             Search Party          Adventure,Comedy   \n",
       "999  1000               Nine Lives     Comedy,Family,Fantasy   \n",
       "\n",
       "                                           Description              Director  \\\n",
       "0    A group of intergalactic criminals are forced ...            James Gunn   \n",
       "1    Following clues to the origin of mankind, a te...          Ridley Scott   \n",
       "2    Three girls are kidnapped by a man with a diag...    M. Night Shyamalan   \n",
       "3    In a city of humanoid animals, a hustling thea...  Christophe Lourdelet   \n",
       "4    A secret government agency recruits some of th...            David Ayer   \n",
       "..                                                 ...                   ...   \n",
       "995  A tight-knit team of rising investigators, alo...             Billy Ray   \n",
       "996  Three American college students studying abroa...              Eli Roth   \n",
       "997  Romantic sparks occur between two dance studen...            Jon M. Chu   \n",
       "998  A pair of friends embark on a mission to reuni...        Scot Armstrong   \n",
       "999  A stuffy businessman finds himself trapped ins...      Barry Sonnenfeld   \n",
       "\n",
       "                                                Actors  Year  \\\n",
       "0    Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...  2014   \n",
       "1    Noomi Rapace, Logan Marshall-Green, Michael Fa...  2012   \n",
       "2    James McAvoy, Anya Taylor-Joy, Haley Lu Richar...  2016   \n",
       "3    Matthew McConaughey,Reese Witherspoon, Seth Ma...  2016   \n",
       "4    Will Smith, Jared Leto, Margot Robbie, Viola D...  2016   \n",
       "..                                                 ...   ...   \n",
       "995  Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...  2015   \n",
       "996  Lauren German, Heather Matarazzo, Bijou Philli...  2007   \n",
       "997  Robert Hoffman, Briana Evigan, Cassie Ventura,...  2008   \n",
       "998  Adam Pally, T.J. Miller, Thomas Middleditch,Sh...  2014   \n",
       "999  Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...  2016   \n",
       "\n",
       "     Runtime (Minutes)  Rating   Votes  Revenue (Millions)  Metascore  \n",
       "0                  121     8.1  757074              333.13       76.0  \n",
       "1                  124     7.0  485820              126.46       65.0  \n",
       "2                  117     7.3  157606              138.12       62.0  \n",
       "3                  108     7.2   60545              270.32       59.0  \n",
       "4                  123     6.2  393727              325.02       40.0  \n",
       "..                 ...     ...     ...                 ...        ...  \n",
       "995                111     6.2   27585                 NaN       45.0  \n",
       "996                 94     5.5   73152               17.54       46.0  \n",
       "997                 98     6.2   70699               58.01       50.0  \n",
       "998                 93     5.6    4881                 NaN       22.0  \n",
       "999                 87     5.3   12435               19.64       11.0  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "given-lightweight",
   "metadata": {},
   "source": [
    "#### 如何判断整个数据集里面是否有空值？\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "heavy-novel",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all([True, True, True])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "chicken-community",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rank                   True\n",
       "Title                  True\n",
       "Genre                  True\n",
       "Description            True\n",
       "Director               True\n",
       "Actors                 True\n",
       "Year                   True\n",
       "Runtime (Minutes)      True\n",
       "Rating                 True\n",
       "Votes                  True\n",
       "Revenue (Millions)    False\n",
       "Metascore             False\n",
       "dtype: bool"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(pd.notnull(movie), axis=0)   # 如果里面有一个缺失值， 那么就会存在false 则最终结果为false，只有当里面全部为True的时候 才会返回True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "id": "clear-google",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie1 = movie.dropna()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "speaking-nightmare",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(pd.notnull(movie1))   # 丢弃掉后，就没有缺失值了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "million-field",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "82.95637614678898"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie['Revenue (Millions)'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "antique-china",
   "metadata": {},
   "outputs": [],
   "source": [
    "{'Metascore': movie['Metascore'].mean(), 'Revenue (Millions)': movie['Revenue (Millions)'].mean()}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "written-alcohol",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie.fillna({'Metascore': movie['Metascore'].mean(), 'Revenue (Millions)': movie['Revenue (Millions)'].mean()}, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "white-inflation",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Rank</th>\n",
       "      <th>Title</th>\n",
       "      <th>Genre</th>\n",
       "      <th>Description</th>\n",
       "      <th>Director</th>\n",
       "      <th>Actors</th>\n",
       "      <th>Year</th>\n",
       "      <th>Runtime (Minutes)</th>\n",
       "      <th>Rating</th>\n",
       "      <th>Votes</th>\n",
       "      <th>Revenue (Millions)</th>\n",
       "      <th>Metascore</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Guardians of the Galaxy</td>\n",
       "      <td>Action,Adventure,Sci-Fi</td>\n",
       "      <td>A group of intergalactic criminals are forced ...</td>\n",
       "      <td>James Gunn</td>\n",
       "      <td>Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...</td>\n",
       "      <td>2014</td>\n",
       "      <td>121</td>\n",
       "      <td>8.1</td>\n",
       "      <td>757074</td>\n",
       "      <td>333.130000</td>\n",
       "      <td>76.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Prometheus</td>\n",
       "      <td>Adventure,Mystery,Sci-Fi</td>\n",
       "      <td>Following clues to the origin of mankind, a te...</td>\n",
       "      <td>Ridley Scott</td>\n",
       "      <td>Noomi Rapace, Logan Marshall-Green, Michael Fa...</td>\n",
       "      <td>2012</td>\n",
       "      <td>124</td>\n",
       "      <td>7.0</td>\n",
       "      <td>485820</td>\n",
       "      <td>126.460000</td>\n",
       "      <td>65.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Split</td>\n",
       "      <td>Horror,Thriller</td>\n",
       "      <td>Three girls are kidnapped by a man with a diag...</td>\n",
       "      <td>M. Night Shyamalan</td>\n",
       "      <td>James McAvoy, Anya Taylor-Joy, Haley Lu Richar...</td>\n",
       "      <td>2016</td>\n",
       "      <td>117</td>\n",
       "      <td>7.3</td>\n",
       "      <td>157606</td>\n",
       "      <td>138.120000</td>\n",
       "      <td>62.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Sing</td>\n",
       "      <td>Animation,Comedy,Family</td>\n",
       "      <td>In a city of humanoid animals, a hustling thea...</td>\n",
       "      <td>Christophe Lourdelet</td>\n",
       "      <td>Matthew McConaughey,Reese Witherspoon, Seth Ma...</td>\n",
       "      <td>2016</td>\n",
       "      <td>108</td>\n",
       "      <td>7.2</td>\n",
       "      <td>60545</td>\n",
       "      <td>270.320000</td>\n",
       "      <td>59.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Suicide Squad</td>\n",
       "      <td>Action,Adventure,Fantasy</td>\n",
       "      <td>A secret government agency recruits some of th...</td>\n",
       "      <td>David Ayer</td>\n",
       "      <td>Will Smith, Jared Leto, Margot Robbie, Viola D...</td>\n",
       "      <td>2016</td>\n",
       "      <td>123</td>\n",
       "      <td>6.2</td>\n",
       "      <td>393727</td>\n",
       "      <td>325.020000</td>\n",
       "      <td>40.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>995</th>\n",
       "      <td>996</td>\n",
       "      <td>Secret in Their Eyes</td>\n",
       "      <td>Crime,Drama,Mystery</td>\n",
       "      <td>A tight-knit team of rising investigators, alo...</td>\n",
       "      <td>Billy Ray</td>\n",
       "      <td>Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...</td>\n",
       "      <td>2015</td>\n",
       "      <td>111</td>\n",
       "      <td>6.2</td>\n",
       "      <td>27585</td>\n",
       "      <td>82.956376</td>\n",
       "      <td>45.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>996</th>\n",
       "      <td>997</td>\n",
       "      <td>Hostel: Part II</td>\n",
       "      <td>Horror</td>\n",
       "      <td>Three American college students studying abroa...</td>\n",
       "      <td>Eli Roth</td>\n",
       "      <td>Lauren German, Heather Matarazzo, Bijou Philli...</td>\n",
       "      <td>2007</td>\n",
       "      <td>94</td>\n",
       "      <td>5.5</td>\n",
       "      <td>73152</td>\n",
       "      <td>17.540000</td>\n",
       "      <td>46.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>997</th>\n",
       "      <td>998</td>\n",
       "      <td>Step Up 2: The Streets</td>\n",
       "      <td>Drama,Music,Romance</td>\n",
       "      <td>Romantic sparks occur between two dance studen...</td>\n",
       "      <td>Jon M. Chu</td>\n",
       "      <td>Robert Hoffman, Briana Evigan, Cassie Ventura,...</td>\n",
       "      <td>2008</td>\n",
       "      <td>98</td>\n",
       "      <td>6.2</td>\n",
       "      <td>70699</td>\n",
       "      <td>58.010000</td>\n",
       "      <td>50.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>998</th>\n",
       "      <td>999</td>\n",
       "      <td>Search Party</td>\n",
       "      <td>Adventure,Comedy</td>\n",
       "      <td>A pair of friends embark on a mission to reuni...</td>\n",
       "      <td>Scot Armstrong</td>\n",
       "      <td>Adam Pally, T.J. Miller, Thomas Middleditch,Sh...</td>\n",
       "      <td>2014</td>\n",
       "      <td>93</td>\n",
       "      <td>5.6</td>\n",
       "      <td>4881</td>\n",
       "      <td>82.956376</td>\n",
       "      <td>22.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>999</th>\n",
       "      <td>1000</td>\n",
       "      <td>Nine Lives</td>\n",
       "      <td>Comedy,Family,Fantasy</td>\n",
       "      <td>A stuffy businessman finds himself trapped ins...</td>\n",
       "      <td>Barry Sonnenfeld</td>\n",
       "      <td>Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...</td>\n",
       "      <td>2016</td>\n",
       "      <td>87</td>\n",
       "      <td>5.3</td>\n",
       "      <td>12435</td>\n",
       "      <td>19.640000</td>\n",
       "      <td>11.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1000 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     Rank                    Title                     Genre  \\\n",
       "0       1  Guardians of the Galaxy   Action,Adventure,Sci-Fi   \n",
       "1       2               Prometheus  Adventure,Mystery,Sci-Fi   \n",
       "2       3                    Split           Horror,Thriller   \n",
       "3       4                     Sing   Animation,Comedy,Family   \n",
       "4       5            Suicide Squad  Action,Adventure,Fantasy   \n",
       "..    ...                      ...                       ...   \n",
       "995   996     Secret in Their Eyes       Crime,Drama,Mystery   \n",
       "996   997          Hostel: Part II                    Horror   \n",
       "997   998   Step Up 2: The Streets       Drama,Music,Romance   \n",
       "998   999             Search Party          Adventure,Comedy   \n",
       "999  1000               Nine Lives     Comedy,Family,Fantasy   \n",
       "\n",
       "                                           Description              Director  \\\n",
       "0    A group of intergalactic criminals are forced ...            James Gunn   \n",
       "1    Following clues to the origin of mankind, a te...          Ridley Scott   \n",
       "2    Three girls are kidnapped by a man with a diag...    M. Night Shyamalan   \n",
       "3    In a city of humanoid animals, a hustling thea...  Christophe Lourdelet   \n",
       "4    A secret government agency recruits some of th...            David Ayer   \n",
       "..                                                 ...                   ...   \n",
       "995  A tight-knit team of rising investigators, alo...             Billy Ray   \n",
       "996  Three American college students studying abroa...              Eli Roth   \n",
       "997  Romantic sparks occur between two dance studen...            Jon M. Chu   \n",
       "998  A pair of friends embark on a mission to reuni...        Scot Armstrong   \n",
       "999  A stuffy businessman finds himself trapped ins...      Barry Sonnenfeld   \n",
       "\n",
       "                                                Actors  Year  \\\n",
       "0    Chris Pratt, Vin Diesel, Bradley Cooper, Zoe S...  2014   \n",
       "1    Noomi Rapace, Logan Marshall-Green, Michael Fa...  2012   \n",
       "2    James McAvoy, Anya Taylor-Joy, Haley Lu Richar...  2016   \n",
       "3    Matthew McConaughey,Reese Witherspoon, Seth Ma...  2016   \n",
       "4    Will Smith, Jared Leto, Margot Robbie, Viola D...  2016   \n",
       "..                                                 ...   ...   \n",
       "995  Chiwetel Ejiofor, Nicole Kidman, Julia Roberts...  2015   \n",
       "996  Lauren German, Heather Matarazzo, Bijou Philli...  2007   \n",
       "997  Robert Hoffman, Briana Evigan, Cassie Ventura,...  2008   \n",
       "998  Adam Pally, T.J. Miller, Thomas Middleditch,Sh...  2014   \n",
       "999  Kevin Spacey, Jennifer Garner, Robbie Amell,Ch...  2016   \n",
       "\n",
       "     Runtime (Minutes)  Rating   Votes  Revenue (Millions)  Metascore  \n",
       "0                  121     8.1  757074          333.130000       76.0  \n",
       "1                  124     7.0  485820          126.460000       65.0  \n",
       "2                  117     7.3  157606          138.120000       62.0  \n",
       "3                  108     7.2   60545          270.320000       59.0  \n",
       "4                  123     6.2  393727          325.020000       40.0  \n",
       "..                 ...     ...     ...                 ...        ...  \n",
       "995                111     6.2   27585           82.956376       45.0  \n",
       "996                 94     5.5   73152           17.540000       46.0  \n",
       "997                 98     6.2   70699           58.010000       50.0  \n",
       "998                 93     5.6    4881           82.956376       22.0  \n",
       "999                 87     5.3   12435           19.640000       11.0  \n",
       "\n",
       "[1000 rows x 12 columns]"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movie"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "natural-silicon",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Rank                  True\n",
       "Title                 True\n",
       "Genre                 True\n",
       "Description           True\n",
       "Director              True\n",
       "Actors                True\n",
       "Year                  True\n",
       "Runtime (Minutes)     True\n",
       "Rating                True\n",
       "Votes                 True\n",
       "Revenue (Millions)    True\n",
       "Metascore             True\n",
       "dtype: bool"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.all(pd.notnull(movie), axis=0)  # 填充平均值完成，看是否还有缺失值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "id": "similar-funeral",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_5 = pd.read_csv('data/stock_day_head5.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "northern-declaration",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>?</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-02-26</td>\n",
       "      <td>22.8</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-02-23</td>\n",
       "      <td>22.88</td>\n",
       "      <td>!</td>\n",
       "      <td>22.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-02-22</td>\n",
       "      <td>#</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-02-14</td>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0   open   high  close\n",
       "0  2018-02-27  23.53  25.88      ?\n",
       "1  2018-02-26   22.8  23.78  23.53\n",
       "2  2018-02-23  22.88      !  22.82\n",
       "3  2018-02-22      #  22.76  22.28\n",
       "4  2018-02-14  21.49  21.99  21.92"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "id": "cultural-domestic",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_5.replace(to_replace=['?','!','#'], value=np.nan, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 135,
   "id": "internal-sound",
   "metadata": {},
   "outputs": [],
   "source": [
    "stock_5 = stock_5.astype({'open': 'float64', 'high': 'float64', 'close': 'float64'})   \n",
    "# 读取进来的数据类型为 object， 我们要将数据转换成 float64, 才能求平均值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "bacterial-round",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-02-27</td>\n",
       "      <td>23.530</td>\n",
       "      <td>25.88</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-02-26</td>\n",
       "      <td>22.800</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-02-23</td>\n",
       "      <td>22.880</td>\n",
       "      <td>21.99</td>\n",
       "      <td>22.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-02-22</td>\n",
       "      <td>22.675</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-02-14</td>\n",
       "      <td>21.490</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0    open   high  close\n",
       "0  2018-02-27  23.530  25.88  23.53\n",
       "1  2018-02-26  22.800  23.78  23.53\n",
       "2  2018-02-23  22.880  21.99  22.82\n",
       "3  2018-02-22  22.675  22.76  22.28\n",
       "4  2018-02-14  21.490  21.99  21.92"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "stock_5.fillna({'open': stock_5['open'].mean(),  'high': stock_5['high'].min(),  'close': stock_5['close'].max(),    })"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "agreed-confusion",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "alien-audio",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张三</th>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>李四</th>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别\n",
       "张三   1\n",
       "李四   2"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame([[1],[2]], index=['张三','李四'], columns=['性别'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "connected-creek",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>性别男</th>\n",
       "      <th>性别女</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张三</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>李四</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "    性别男  性别女\n",
       "张三    1    0\n",
       "李四    0    1"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.DataFrame([[1,0],[0,1]], index=['张三','李四'], columns=['性别男','性别女'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "built-participation",
   "metadata": {},
   "source": [
    "### 数据离散化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "phantom-polls",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "returning-midwest",
   "metadata": {},
   "outputs": [],
   "source": [
    "data = pd.read_csv(\"./data/stock_day.csv\")\n",
    "p_change= data['p_change']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "thermal-western",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>open</th>\n",
       "      <th>high</th>\n",
       "      <th>close</th>\n",
       "      <th>low</th>\n",
       "      <th>volume</th>\n",
       "      <th>price_change</th>\n",
       "      <th>p_change</th>\n",
       "      <th>ma5</th>\n",
       "      <th>ma10</th>\n",
       "      <th>ma20</th>\n",
       "      <th>v_ma5</th>\n",
       "      <th>v_ma10</th>\n",
       "      <th>v_ma20</th>\n",
       "      <th>turnover</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>23.53</td>\n",
       "      <td>25.88</td>\n",
       "      <td>24.16</td>\n",
       "      <td>23.53</td>\n",
       "      <td>95578.03</td>\n",
       "      <td>0.63</td>\n",
       "      <td>2.68</td>\n",
       "      <td>22.942</td>\n",
       "      <td>22.142</td>\n",
       "      <td>22.875</td>\n",
       "      <td>53782.64</td>\n",
       "      <td>46738.65</td>\n",
       "      <td>55576.11</td>\n",
       "      <td>2.39</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>22.80</td>\n",
       "      <td>23.78</td>\n",
       "      <td>23.53</td>\n",
       "      <td>22.80</td>\n",
       "      <td>60985.11</td>\n",
       "      <td>0.69</td>\n",
       "      <td>3.02</td>\n",
       "      <td>22.406</td>\n",
       "      <td>21.955</td>\n",
       "      <td>22.942</td>\n",
       "      <td>40827.52</td>\n",
       "      <td>42736.34</td>\n",
       "      <td>56007.50</td>\n",
       "      <td>1.53</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>22.88</td>\n",
       "      <td>23.37</td>\n",
       "      <td>22.82</td>\n",
       "      <td>22.71</td>\n",
       "      <td>52914.01</td>\n",
       "      <td>0.54</td>\n",
       "      <td>2.42</td>\n",
       "      <td>21.938</td>\n",
       "      <td>21.929</td>\n",
       "      <td>23.022</td>\n",
       "      <td>35119.58</td>\n",
       "      <td>41871.97</td>\n",
       "      <td>56372.85</td>\n",
       "      <td>1.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>22.25</td>\n",
       "      <td>22.76</td>\n",
       "      <td>22.28</td>\n",
       "      <td>22.02</td>\n",
       "      <td>36105.01</td>\n",
       "      <td>0.36</td>\n",
       "      <td>1.64</td>\n",
       "      <td>21.446</td>\n",
       "      <td>21.909</td>\n",
       "      <td>23.137</td>\n",
       "      <td>35397.58</td>\n",
       "      <td>39904.78</td>\n",
       "      <td>60149.60</td>\n",
       "      <td>0.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>21.49</td>\n",
       "      <td>21.99</td>\n",
       "      <td>21.92</td>\n",
       "      <td>21.48</td>\n",
       "      <td>23331.04</td>\n",
       "      <td>0.44</td>\n",
       "      <td>2.05</td>\n",
       "      <td>21.366</td>\n",
       "      <td>21.923</td>\n",
       "      <td>23.253</td>\n",
       "      <td>33590.21</td>\n",
       "      <td>42935.74</td>\n",
       "      <td>61716.11</td>\n",
       "      <td>0.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>13.17</td>\n",
       "      <td>14.48</td>\n",
       "      <td>14.28</td>\n",
       "      <td>13.13</td>\n",
       "      <td>179831.72</td>\n",
       "      <td>1.12</td>\n",
       "      <td>8.51</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>13.112</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>115090.18</td>\n",
       "      <td>6.16</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>12.88</td>\n",
       "      <td>13.45</td>\n",
       "      <td>13.16</td>\n",
       "      <td>12.87</td>\n",
       "      <td>93180.39</td>\n",
       "      <td>0.26</td>\n",
       "      <td>2.02</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>12.820</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>98904.79</td>\n",
       "      <td>3.19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>12.80</td>\n",
       "      <td>12.92</td>\n",
       "      <td>12.90</td>\n",
       "      <td>12.61</td>\n",
       "      <td>67075.44</td>\n",
       "      <td>0.20</td>\n",
       "      <td>1.57</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>12.707</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>100812.93</td>\n",
       "      <td>2.30</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>12.52</td>\n",
       "      <td>13.06</td>\n",
       "      <td>12.70</td>\n",
       "      <td>12.52</td>\n",
       "      <td>139071.61</td>\n",
       "      <td>0.18</td>\n",
       "      <td>1.44</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>12.610</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>117681.67</td>\n",
       "      <td>4.76</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>12.25</td>\n",
       "      <td>12.67</td>\n",
       "      <td>12.52</td>\n",
       "      <td>12.20</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>0.32</td>\n",
       "      <td>2.62</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>12.520</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>96291.73</td>\n",
       "      <td>3.30</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 14 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "             open   high  close    low     volume  price_change  p_change  \\\n",
       "2018-02-27  23.53  25.88  24.16  23.53   95578.03          0.63      2.68   \n",
       "2018-02-26  22.80  23.78  23.53  22.80   60985.11          0.69      3.02   \n",
       "2018-02-23  22.88  23.37  22.82  22.71   52914.01          0.54      2.42   \n",
       "2018-02-22  22.25  22.76  22.28  22.02   36105.01          0.36      1.64   \n",
       "2018-02-14  21.49  21.99  21.92  21.48   23331.04          0.44      2.05   \n",
       "...           ...    ...    ...    ...        ...           ...       ...   \n",
       "2015-03-06  13.17  14.48  14.28  13.13  179831.72          1.12      8.51   \n",
       "2015-03-05  12.88  13.45  13.16  12.87   93180.39          0.26      2.02   \n",
       "2015-03-04  12.80  12.92  12.90  12.61   67075.44          0.20      1.57   \n",
       "2015-03-03  12.52  13.06  12.70  12.52  139071.61          0.18      1.44   \n",
       "2015-03-02  12.25  12.67  12.52  12.20   96291.73          0.32      2.62   \n",
       "\n",
       "               ma5    ma10    ma20      v_ma5     v_ma10     v_ma20  turnover  \n",
       "2018-02-27  22.942  22.142  22.875   53782.64   46738.65   55576.11      2.39  \n",
       "2018-02-26  22.406  21.955  22.942   40827.52   42736.34   56007.50      1.53  \n",
       "2018-02-23  21.938  21.929  23.022   35119.58   41871.97   56372.85      1.32  \n",
       "2018-02-22  21.446  21.909  23.137   35397.58   39904.78   60149.60      0.90  \n",
       "2018-02-14  21.366  21.923  23.253   33590.21   42935.74   61716.11      0.58  \n",
       "...            ...     ...     ...        ...        ...        ...       ...  \n",
       "2015-03-06  13.112  13.112  13.112  115090.18  115090.18  115090.18      6.16  \n",
       "2015-03-05  12.820  12.820  12.820   98904.79   98904.79   98904.79      3.19  \n",
       "2015-03-04  12.707  12.707  12.707  100812.93  100812.93  100812.93      2.30  \n",
       "2015-03-03  12.610  12.610  12.610  117681.67  117681.67  117681.67      4.76  \n",
       "2015-03-02  12.520  12.520  12.520   96291.73   96291.73   96291.73      3.30  \n",
       "\n",
       "[643 rows x 14 columns]"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "therapeutic-governor",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(-0.001, 0.332]    65\n",
       "(0.332, 0.73]      65\n",
       "(0.73, 1.106]      63\n",
       "(1.106, 1.57]      67\n",
       "(1.57, 2.1]        64\n",
       "(2.1, 2.802]       62\n",
       "(2.802, 3.662]     64\n",
       "(3.662, 5.11]      65\n",
       "(5.11, 7.198]      63\n",
       "(7.198, 10.03]     65\n",
       "Name: p_change, dtype: int64"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "qcut = pd.qcut(np.abs(p_change), 10)\n",
    "qcut.value_counts().sort_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "distinguished-parliament",
   "metadata": {},
   "outputs": [],
   "source": [
    "dummaries10 = pd.get_dummies(qcut, prefix=\"p_change\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "signal-hamilton",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>p_change_(-0.001, 0.332]</th>\n",
       "      <th>p_change_(0.332, 0.73]</th>\n",
       "      <th>p_change_(0.73, 1.106]</th>\n",
       "      <th>p_change_(1.106, 1.57]</th>\n",
       "      <th>p_change_(1.57, 2.1]</th>\n",
       "      <th>p_change_(2.1, 2.802]</th>\n",
       "      <th>p_change_(2.802, 3.662]</th>\n",
       "      <th>p_change_(3.662, 5.11]</th>\n",
       "      <th>p_change_(5.11, 7.198]</th>\n",
       "      <th>p_change_(7.198, 10.03]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            p_change_(-0.001, 0.332]  p_change_(0.332, 0.73]  \\\n",
       "2018-02-27                         0                       0   \n",
       "2018-02-26                         0                       0   \n",
       "2018-02-23                         0                       0   \n",
       "2018-02-22                         0                       0   \n",
       "2018-02-14                         0                       0   \n",
       "...                              ...                     ...   \n",
       "2015-03-06                         0                       0   \n",
       "2015-03-05                         0                       0   \n",
       "2015-03-04                         0                       0   \n",
       "2015-03-03                         0                       0   \n",
       "2015-03-02                         0                       0   \n",
       "\n",
       "            p_change_(0.73, 1.106]  p_change_(1.106, 1.57]  \\\n",
       "2018-02-27                       0                       0   \n",
       "2018-02-26                       0                       0   \n",
       "2018-02-23                       0                       0   \n",
       "2018-02-22                       0                       0   \n",
       "2018-02-14                       0                       0   \n",
       "...                            ...                     ...   \n",
       "2015-03-06                       0                       0   \n",
       "2015-03-05                       0                       0   \n",
       "2015-03-04                       0                       1   \n",
       "2015-03-03                       0                       1   \n",
       "2015-03-02                       0                       0   \n",
       "\n",
       "            p_change_(1.57, 2.1]  p_change_(2.1, 2.802]  \\\n",
       "2018-02-27                     0                      1   \n",
       "2018-02-26                     0                      0   \n",
       "2018-02-23                     0                      1   \n",
       "2018-02-22                     1                      0   \n",
       "2018-02-14                     1                      0   \n",
       "...                          ...                    ...   \n",
       "2015-03-06                     0                      0   \n",
       "2015-03-05                     1                      0   \n",
       "2015-03-04                     0                      0   \n",
       "2015-03-03                     0                      0   \n",
       "2015-03-02                     0                      1   \n",
       "\n",
       "            p_change_(2.802, 3.662]  p_change_(3.662, 5.11]  \\\n",
       "2018-02-27                        0                       0   \n",
       "2018-02-26                        1                       0   \n",
       "2018-02-23                        0                       0   \n",
       "2018-02-22                        0                       0   \n",
       "2018-02-14                        0                       0   \n",
       "...                             ...                     ...   \n",
       "2015-03-06                        0                       0   \n",
       "2015-03-05                        0                       0   \n",
       "2015-03-04                        0                       0   \n",
       "2015-03-03                        0                       0   \n",
       "2015-03-02                        0                       0   \n",
       "\n",
       "            p_change_(5.11, 7.198]  p_change_(7.198, 10.03]  \n",
       "2018-02-27                       0                        0  \n",
       "2018-02-26                       0                        0  \n",
       "2018-02-23                       0                        0  \n",
       "2018-02-22                       0                        0  \n",
       "2018-02-14                       0                        0  \n",
       "...                            ...                      ...  \n",
       "2015-03-06                       0                        1  \n",
       "2015-03-05                       0                        0  \n",
       "2015-03-04                       0                        0  \n",
       "2015-03-03                       0                        0  \n",
       "2015-03-02                       0                        0  \n",
       "\n",
       "[643 rows x 10 columns]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dummaries10"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "honey-acceptance",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 自己指定分组区间\n",
    "bins = [-100, -7, -5, -3, 0, 3, 5, 7, 100]\n",
    "p_counts = pd.cut(p_change, bins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "fossil-search",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rise_(-100, -7]</th>\n",
       "      <th>rise_(-7, -5]</th>\n",
       "      <th>rise_(-5, -3]</th>\n",
       "      <th>rise_(-3, 0]</th>\n",
       "      <th>rise_(0, 3]</th>\n",
       "      <th>rise_(3, 5]</th>\n",
       "      <th>rise_(5, 7]</th>\n",
       "      <th>rise_(7, 100]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-02-27</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-26</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-23</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-22</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-14</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-06</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-05</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-04</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-03</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2015-03-02</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>643 rows × 8 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            rise_(-100, -7]  rise_(-7, -5]  rise_(-5, -3]  rise_(-3, 0]  \\\n",
       "2018-02-27                0              0              0             0   \n",
       "2018-02-26                0              0              0             0   \n",
       "2018-02-23                0              0              0             0   \n",
       "2018-02-22                0              0              0             0   \n",
       "2018-02-14                0              0              0             0   \n",
       "...                     ...            ...            ...           ...   \n",
       "2015-03-06                0              0              0             0   \n",
       "2015-03-05                0              0              0             0   \n",
       "2015-03-04                0              0              0             0   \n",
       "2015-03-03                0              0              0             0   \n",
       "2015-03-02                0              0              0             0   \n",
       "\n",
       "            rise_(0, 3]  rise_(3, 5]  rise_(5, 7]  rise_(7, 100]  \n",
       "2018-02-27            1            0            0              0  \n",
       "2018-02-26            0            1            0              0  \n",
       "2018-02-23            1            0            0              0  \n",
       "2018-02-22            1            0            0              0  \n",
       "2018-02-14            1            0            0              0  \n",
       "...                 ...          ...          ...            ...  \n",
       "2015-03-06            0            0            0              1  \n",
       "2015-03-05            1            0            0              0  \n",
       "2015-03-04            1            0            0              0  \n",
       "2015-03-03            1            0            0              0  \n",
       "2015-03-02            1            0            0              0  \n",
       "\n",
       "[643 rows x 8 columns]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.get_dummies(p_counts, prefix=\"rise\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "subtle-abuse",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 1. 模拟身高数据\n",
    "man_high = np.random.normal(165, 8, size=(100))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "military-passenger",
   "metadata": {},
   "outputs": [],
   "source": [
    "names = ['张'+ str(i) for i in range(len(man_high))]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "difficult-daughter",
   "metadata": {},
   "outputs": [],
   "source": [
    "man_high = man_high.round(1) # 保留小数点后1位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "behavioral-ideal",
   "metadata": {},
   "outputs": [],
   "source": [
    "man_high_df = pd.DataFrame(man_high, index=names, columns=['身高'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "bigger-manufacturer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>身高</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张0</th>\n",
       "      <td>152.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张1</th>\n",
       "      <td>155.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张2</th>\n",
       "      <td>159.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张3</th>\n",
       "      <td>159.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张4</th>\n",
       "      <td>149.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张95</th>\n",
       "      <td>171.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张96</th>\n",
       "      <td>157.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张97</th>\n",
       "      <td>169.3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张98</th>\n",
       "      <td>166.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张99</th>\n",
       "      <td>161.4</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        身高\n",
       "张0   152.8\n",
       "张1   155.8\n",
       "张2   159.3\n",
       "张3   159.3\n",
       "张4   149.8\n",
       "..     ...\n",
       "张95  171.4\n",
       "张96  157.4\n",
       "张97  169.3\n",
       "张98  166.4\n",
       "张99  161.4\n",
       "\n",
       "[100 rows x 1 columns]"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "man_high_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "democratic-farmer",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(185.6, 144.9)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "man_high.max(), man_high.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "stylish-burton",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 2. 对身高数据做离散化    [140,150,160,170,180,190]\n",
    "bins = [140,150,160,170,180,190]\n",
    "high_counts = pd.cut(man_high_df['身高'], bins)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "superior-government",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>身高_(140, 150]</th>\n",
       "      <th>身高_(150, 160]</th>\n",
       "      <th>身高_(160, 170]</th>\n",
       "      <th>身高_(170, 180]</th>\n",
       "      <th>身高_(180, 190]</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>张0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张1</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张2</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张3</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张4</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张95</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张96</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张97</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张98</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>张99</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>100 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     身高_(140, 150]  身高_(150, 160]  身高_(160, 170]  身高_(170, 180]  身高_(180, 190]\n",
       "张0               0              1              0              0              0\n",
       "张1               0              1              0              0              0\n",
       "张2               0              1              0              0              0\n",
       "张3               0              1              0              0              0\n",
       "张4               1              0              0              0              0\n",
       "..             ...            ...            ...            ...            ...\n",
       "张95              0              0              0              1              0\n",
       "张96              0              1              0              0              0\n",
       "张97              0              0              1              0              0\n",
       "张98              0              0              1              0              0\n",
       "张99              0              0              1              0              0\n",
       "\n",
       "[100 rows x 5 columns]"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 3. 输出哑变量矩阵\n",
    "pd.get_dummies(high_counts, prefix='身高')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "molecular-rocket",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "competent-tractor",
   "metadata": {},
   "outputs": [],
   "source": [
    "left = pd.DataFrame({'key1': ['K0', 'K0', 'K1', 'K2'],\n",
    "                        'key2': ['K0', 'K1', 'K0', 'K1'],\n",
    "                        'A': ['A0', 'A1', 'A2', 'A3'],\n",
    "                        'B': ['B0', 'B1', 'B2', 'B3']})\n",
    "\n",
    "right = pd.DataFrame({'key1': ['K0', 'K1', 'K1', 'K2'],\n",
    "                        'key2': ['K0', 'K0', 'K0', 'K0'],\n",
    "                        'C': ['C0', 'C1', 'C2', 'C3'],\n",
    "                        'D': ['D0', 'D1', 'D2', 'D3']})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "universal-bunch",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B\n",
       "0   K0   K0  A0  B0\n",
       "1   K0   K1  A1  B1\n",
       "2   K1   K0  A2  B2\n",
       "3   K2   K1  A3  B3"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "left"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "copyrighted-chicago",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   C   D\n",
       "0   K0   K0  C0  D0\n",
       "1   K1   K0  C1  D1\n",
       "2   K1   K0  C2  D2\n",
       "3   K2   K0  C3  D3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "right"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "blind-family",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B   C   D\n",
       "0   K0   K0  A0  B0  C0  D0\n",
       "1   K1   K0  A2  B2  C1  D1\n",
       "2   K1   K0  A2  B2  C2  D2"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 默认内连接\n",
    "pd.merge(left, right, on=['key1', 'key2'])\n",
    "# 内连接， 两边存在相同的key的数据保留下来"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "stainless-camping",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2   A   B    C    D\n",
       "0   K0   K0  A0  B0   C0   D0\n",
       "1   K0   K1  A1  B1  NaN  NaN\n",
       "2   K1   K0  A2  B2   C1   D1\n",
       "3   K1   K0  A2  B2   C2   D2\n",
       "4   K2   K1  A3  B3  NaN  NaN"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(left, right, how='left', on=['key1', 'key2'])\n",
    "# 左连接，  以左边为基准，左边有的数据则保留，右边没有对应的key的数据则置空"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "comprehensive-medium",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2    A    B   C   D\n",
       "0   K0   K0   A0   B0  C0  D0\n",
       "1   K1   K0   A2   B2  C1  D1\n",
       "2   K1   K0   A2   B2  C2  D2\n",
       "3   K2   K0  NaN  NaN  C3  D3"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(left, right, how='right', on=['key1', 'key2'])\n",
    "# 右连接，  以右边为基准，右边有的数据则保留，左边没有对应的key的数据则置空"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "subject-prototype",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>key1</th>\n",
       "      <th>key2</th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>K0</td>\n",
       "      <td>K0</td>\n",
       "      <td>A0</td>\n",
       "      <td>B0</td>\n",
       "      <td>C0</td>\n",
       "      <td>D0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>K0</td>\n",
       "      <td>K1</td>\n",
       "      <td>A1</td>\n",
       "      <td>B1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C1</td>\n",
       "      <td>D1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>K1</td>\n",
       "      <td>K0</td>\n",
       "      <td>A2</td>\n",
       "      <td>B2</td>\n",
       "      <td>C2</td>\n",
       "      <td>D2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>K2</td>\n",
       "      <td>K1</td>\n",
       "      <td>A3</td>\n",
       "      <td>B3</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>K2</td>\n",
       "      <td>K0</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>C3</td>\n",
       "      <td>D3</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  key1 key2    A    B    C    D\n",
       "0   K0   K0   A0   B0   C0   D0\n",
       "1   K0   K1   A1   B1  NaN  NaN\n",
       "2   K1   K0   A2   B2   C1   D1\n",
       "3   K1   K0   A2   B2   C2   D2\n",
       "4   K2   K1   A3   B3  NaN  NaN\n",
       "5   K2   K0  NaN  NaN   C3   D3"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.merge(left, right, how='outer', on=['key1', 'key2'])\n",
    "# 两边数据均保留，对方没有对应的key的数据则置空"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "diverse-hardware",
   "metadata": {},
   "source": [
    "### 分组聚合"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "streaming-footage",
   "metadata": {},
   "outputs": [],
   "source": [
    "col =pd.DataFrame({'color': ['white','red','green','red','green'], 'object': ['pen','pencil','pencil','ashtray','pen'],'price1':[5.56,4.20,1.30,0.56,2.75],'price2':[4.75,4.12,1.60,0.75,3.15]})\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "signed-cornell",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>object</th>\n",
       "      <th>price1</th>\n",
       "      <th>price2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>white</td>\n",
       "      <td>pen</td>\n",
       "      <td>5.56</td>\n",
       "      <td>4.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>red</td>\n",
       "      <td>pencil</td>\n",
       "      <td>4.20</td>\n",
       "      <td>4.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>green</td>\n",
       "      <td>pencil</td>\n",
       "      <td>1.30</td>\n",
       "      <td>1.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>red</td>\n",
       "      <td>ashtray</td>\n",
       "      <td>0.56</td>\n",
       "      <td>0.75</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>green</td>\n",
       "      <td>pen</td>\n",
       "      <td>2.75</td>\n",
       "      <td>3.15</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color   object  price1  price2\n",
       "0  white      pen    5.56    4.75\n",
       "1    red   pencil    4.20    4.12\n",
       "2  green   pencil    1.30    1.60\n",
       "3    red  ashtray    0.56    0.75\n",
       "4  green      pen    2.75    3.15"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "aware-burden",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "color\n",
       "green    2.025\n",
       "red      2.380\n",
       "white    5.560\n",
       "Name: price1, dtype: float64"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组，求平均值\n",
    "col.groupby(['color'])['price1'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "educated-community",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "color\n",
       "green    2.025\n",
       "red      2.380\n",
       "white    5.560\n",
       "Name: price1, dtype: float64"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "col['price1'].groupby(col['color']).mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "inappropriate-consensus",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>color</th>\n",
       "      <th>price1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>green</td>\n",
       "      <td>2.025</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>red</td>\n",
       "      <td>2.380</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>white</td>\n",
       "      <td>5.560</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   color  price1\n",
       "0  green   2.025\n",
       "1    red   2.380\n",
       "2  white   5.560"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 分组，数据的结构不变\n",
    "col.groupby(['color'], as_index=False)['price1'].mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "accompanied-hurricane",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
